
obj/user/sh:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 63 0a 00 00       	call   800a94 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <usage>:
}


void
usage(void)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	83 ec 18             	sub    $0x18,%esp
	cprintf("usage: sh [-dix] [command-file]\n");
  800046:	c7 04 24 e0 3d 80 00 	movl   $0x803de0,(%esp)
  80004d:	e8 73 0b 00 00       	call   800bc5 <cprintf>
	exit();
  800052:	e8 8d 0a 00 00       	call   800ae4 <exit>
}
  800057:	c9                   	leave  
  800058:	c3                   	ret    

00800059 <_gettoken>:
#define WHITESPACE " \t\r\n"
#define SYMBOLS "<|>&;()"

int
_gettoken(char *s, char **p1, char **p2)
{
  800059:	55                   	push   %ebp
  80005a:	89 e5                	mov    %esp,%ebp
  80005c:	57                   	push   %edi
  80005d:	56                   	push   %esi
  80005e:	53                   	push   %ebx
  80005f:	83 ec 1c             	sub    $0x1c,%esp
  800062:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int t;

	if (s == 0) {
  800065:	85 db                	test   %ebx,%ebx
  800067:	75 23                	jne    80008c <_gettoken+0x33>
		if (debug > 1)
  800069:	83 3d 80 80 80 00 01 	cmpl   $0x1,0x808080
  800070:	0f 8e 42 01 00 00    	jle    8001b8 <_gettoken+0x15f>
			cprintf("GETTOKEN NULL\n");
  800076:	c7 04 24 52 3e 80 00 	movl   $0x803e52,(%esp)
  80007d:	e8 43 0b 00 00       	call   800bc5 <cprintf>
  800082:	be 00 00 00 00       	mov    $0x0,%esi
  800087:	e9 31 01 00 00       	jmp    8001bd <_gettoken+0x164>
		return 0;
	}

	if (debug > 1)
  80008c:	83 3d 80 80 80 00 01 	cmpl   $0x1,0x808080
  800093:	7e 10                	jle    8000a5 <_gettoken+0x4c>
		cprintf("GETTOKEN: %s\n", s);
  800095:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800099:	c7 04 24 61 3e 80 00 	movl   $0x803e61,(%esp)
  8000a0:	e8 20 0b 00 00       	call   800bc5 <cprintf>

	*p1 = 0;
  8000a5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8000a8:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	*p2 = 0;
  8000ae:	8b 55 10             	mov    0x10(%ebp),%edx
  8000b1:	c7 02 00 00 00 00    	movl   $0x0,(%edx)

	while (strchr(WHITESPACE, *s))
  8000b7:	eb 06                	jmp    8000bf <_gettoken+0x66>
		*s++ = 0;
  8000b9:	c6 03 00             	movb   $0x0,(%ebx)
  8000bc:	83 c3 01             	add    $0x1,%ebx
		cprintf("GETTOKEN: %s\n", s);

	*p1 = 0;
	*p2 = 0;

	while (strchr(WHITESPACE, *s))
  8000bf:	0f be 03             	movsbl (%ebx),%eax
  8000c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000c6:	c7 04 24 6f 3e 80 00 	movl   $0x803e6f,(%esp)
  8000cd:	e8 bc 13 00 00       	call   80148e <strchr>
  8000d2:	85 c0                	test   %eax,%eax
  8000d4:	75 e3                	jne    8000b9 <_gettoken+0x60>
  8000d6:	89 df                	mov    %ebx,%edi
		*s++ = 0;
	if (*s == 0) {
  8000d8:	0f b6 03             	movzbl (%ebx),%eax
  8000db:	84 c0                	test   %al,%al
  8000dd:	75 23                	jne    800102 <_gettoken+0xa9>
		if (debug > 1)
  8000df:	83 3d 80 80 80 00 01 	cmpl   $0x1,0x808080
  8000e6:	0f 8e cc 00 00 00    	jle    8001b8 <_gettoken+0x15f>
			cprintf("EOL\n");
  8000ec:	c7 04 24 74 3e 80 00 	movl   $0x803e74,(%esp)
  8000f3:	e8 cd 0a 00 00       	call   800bc5 <cprintf>
  8000f8:	be 00 00 00 00       	mov    $0x0,%esi
  8000fd:	e9 bb 00 00 00       	jmp    8001bd <_gettoken+0x164>
		return 0;
	}
	if (strchr(SYMBOLS, *s)) {
  800102:	0f be c0             	movsbl %al,%eax
  800105:	89 44 24 04          	mov    %eax,0x4(%esp)
  800109:	c7 04 24 85 3e 80 00 	movl   $0x803e85,(%esp)
  800110:	e8 79 13 00 00       	call   80148e <strchr>
  800115:	85 c0                	test   %eax,%eax
  800117:	74 32                	je     80014b <_gettoken+0xf2>
		t = *s;
  800119:	0f be 33             	movsbl (%ebx),%esi
		*p1 = s;
  80011c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80011f:	89 18                	mov    %ebx,(%eax)
		*s++ = 0;
  800121:	c6 03 00             	movb   $0x0,(%ebx)
		*p2 = s;
  800124:	83 c7 01             	add    $0x1,%edi
  800127:	8b 55 10             	mov    0x10(%ebp),%edx
  80012a:	89 3a                	mov    %edi,(%edx)
		if (debug > 1)
  80012c:	83 3d 80 80 80 00 01 	cmpl   $0x1,0x808080
  800133:	0f 8e 84 00 00 00    	jle    8001bd <_gettoken+0x164>
			cprintf("TOK %c\n", t);
  800139:	89 74 24 04          	mov    %esi,0x4(%esp)
  80013d:	c7 04 24 79 3e 80 00 	movl   $0x803e79,(%esp)
  800144:	e8 7c 0a 00 00       	call   800bc5 <cprintf>
  800149:	eb 72                	jmp    8001bd <_gettoken+0x164>
		return t;
	}
	*p1 = s;
  80014b:	8b 45 0c             	mov    0xc(%ebp),%eax
  80014e:	89 18                	mov    %ebx,(%eax)
	while (*s && !strchr(WHITESPACE SYMBOLS, *s))
  800150:	0f b6 03             	movzbl (%ebx),%eax
  800153:	84 c0                	test   %al,%al
  800155:	75 0c                	jne    800163 <_gettoken+0x10a>
  800157:	eb 21                	jmp    80017a <_gettoken+0x121>
		s++;
  800159:	83 c3 01             	add    $0x1,%ebx
		if (debug > 1)
			cprintf("TOK %c\n", t);
		return t;
	}
	*p1 = s;
	while (*s && !strchr(WHITESPACE SYMBOLS, *s))
  80015c:	0f b6 03             	movzbl (%ebx),%eax
  80015f:	84 c0                	test   %al,%al
  800161:	74 17                	je     80017a <_gettoken+0x121>
  800163:	0f be c0             	movsbl %al,%eax
  800166:	89 44 24 04          	mov    %eax,0x4(%esp)
  80016a:	c7 04 24 81 3e 80 00 	movl   $0x803e81,(%esp)
  800171:	e8 18 13 00 00       	call   80148e <strchr>
  800176:	85 c0                	test   %eax,%eax
  800178:	74 df                	je     800159 <_gettoken+0x100>
		s++;
	*p2 = s;
  80017a:	8b 55 10             	mov    0x10(%ebp),%edx
  80017d:	89 1a                	mov    %ebx,(%edx)
	if (debug > 1) {
  80017f:	be 77 00 00 00       	mov    $0x77,%esi
  800184:	83 3d 80 80 80 00 01 	cmpl   $0x1,0x808080
  80018b:	7e 30                	jle    8001bd <_gettoken+0x164>
		t = **p2;
  80018d:	0f b6 33             	movzbl (%ebx),%esi
		**p2 = 0;
  800190:	c6 03 00             	movb   $0x0,(%ebx)
		cprintf("WORD: %s\n", *p1);
  800193:	8b 55 0c             	mov    0xc(%ebp),%edx
  800196:	8b 02                	mov    (%edx),%eax
  800198:	89 44 24 04          	mov    %eax,0x4(%esp)
  80019c:	c7 04 24 8d 3e 80 00 	movl   $0x803e8d,(%esp)
  8001a3:	e8 1d 0a 00 00       	call   800bc5 <cprintf>
		**p2 = t;
  8001a8:	8b 55 10             	mov    0x10(%ebp),%edx
  8001ab:	8b 02                	mov    (%edx),%eax
  8001ad:	89 f2                	mov    %esi,%edx
  8001af:	88 10                	mov    %dl,(%eax)
  8001b1:	be 77 00 00 00       	mov    $0x77,%esi
  8001b6:	eb 05                	jmp    8001bd <_gettoken+0x164>
  8001b8:	be 00 00 00 00       	mov    $0x0,%esi
	}
	return 'w';
}
  8001bd:	89 f0                	mov    %esi,%eax
  8001bf:	83 c4 1c             	add    $0x1c,%esp
  8001c2:	5b                   	pop    %ebx
  8001c3:	5e                   	pop    %esi
  8001c4:	5f                   	pop    %edi
  8001c5:	5d                   	pop    %ebp
  8001c6:	c3                   	ret    

008001c7 <gettoken>:

int
gettoken(char *s, char **p1)
{
  8001c7:	55                   	push   %ebp
  8001c8:	89 e5                	mov    %esp,%ebp
  8001ca:	83 ec 18             	sub    $0x18,%esp
  8001cd:	8b 45 08             	mov    0x8(%ebp),%eax
	static int c, nc;
	static char* np1, *np2;

	if (s) {
  8001d0:	85 c0                	test   %eax,%eax
  8001d2:	74 24                	je     8001f8 <gettoken+0x31>
		nc = _gettoken(s, &np1, &np2);
  8001d4:	c7 44 24 08 84 80 80 	movl   $0x808084,0x8(%esp)
  8001db:	00 
  8001dc:	c7 44 24 04 88 80 80 	movl   $0x808088,0x4(%esp)
  8001e3:	00 
  8001e4:	89 04 24             	mov    %eax,(%esp)
  8001e7:	e8 6d fe ff ff       	call   800059 <_gettoken>
  8001ec:	a3 8c 80 80 00       	mov    %eax,0x80808c
  8001f1:	b8 00 00 00 00       	mov    $0x0,%eax
		return 0;
  8001f6:	eb 3c                	jmp    800234 <gettoken+0x6d>
	}
	c = nc;
  8001f8:	a1 8c 80 80 00       	mov    0x80808c,%eax
  8001fd:	a3 90 80 80 00       	mov    %eax,0x808090
	*p1 = np1;
  800202:	8b 15 88 80 80 00    	mov    0x808088,%edx
  800208:	8b 45 0c             	mov    0xc(%ebp),%eax
  80020b:	89 10                	mov    %edx,(%eax)
	nc = _gettoken(np2, &np1, &np2);
  80020d:	c7 44 24 08 84 80 80 	movl   $0x808084,0x8(%esp)
  800214:	00 
  800215:	c7 44 24 04 88 80 80 	movl   $0x808088,0x4(%esp)
  80021c:	00 
  80021d:	a1 84 80 80 00       	mov    0x808084,%eax
  800222:	89 04 24             	mov    %eax,(%esp)
  800225:	e8 2f fe ff ff       	call   800059 <_gettoken>
  80022a:	a3 8c 80 80 00       	mov    %eax,0x80808c
	return c;
  80022f:	a1 90 80 80 00       	mov    0x808090,%eax
}
  800234:	c9                   	leave  
  800235:	c3                   	ret    

00800236 <runcmd>:
// runcmd() is called in a forked child,
// so it's OK to manipulate file descriptor state.
#define MAXARGS 16
void
runcmd(char* s)
{
  800236:	55                   	push   %ebp
  800237:	89 e5                	mov    %esp,%ebp
  800239:	57                   	push   %edi
  80023a:	56                   	push   %esi
  80023b:	53                   	push   %ebx
  80023c:	81 ec 6c 04 00 00    	sub    $0x46c,%esp
	char *argv[MAXARGS], *t, argv0buf[BUFSIZ];
	int argc, c, i, r, p[2], fd, pipe_child;

	pipe_child = 0;
	gettoken(s, 0);
  800242:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800249:	00 
  80024a:	8b 45 08             	mov    0x8(%ebp),%eax
  80024d:	89 04 24             	mov    %eax,(%esp)
  800250:	e8 72 ff ff ff       	call   8001c7 <gettoken>
  800255:	be 00 00 00 00       	mov    $0x0,%esi
	
again:
	argc = 0;
	while (1) {
		switch ((c = gettoken(0, &t))) {
  80025a:	8d 5d a4             	lea    -0x5c(%ebp),%ebx
  80025d:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800261:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800268:	e8 5a ff ff ff       	call   8001c7 <gettoken>
  80026d:	83 f8 77             	cmp    $0x77,%eax
  800270:	74 3b                	je     8002ad <runcmd+0x77>
  800272:	83 f8 77             	cmp    $0x77,%eax
  800275:	7f 24                	jg     80029b <runcmd+0x65>
  800277:	83 f8 3c             	cmp    $0x3c,%eax
  80027a:	74 53                	je     8002cf <runcmd+0x99>
  80027c:	83 f8 3e             	cmp    $0x3e,%eax
  80027f:	90                   	nop
  800280:	0f 84 cd 00 00 00    	je     800353 <runcmd+0x11d>
		case 0:		// String is complete
			// Run the current command!
			goto runit;
			
		default:
			panic("bad return %d from gettoken", c);
  800286:	bf 00 00 00 00       	mov    $0x0,%edi
	gettoken(s, 0);
	
again:
	argc = 0;
	while (1) {
		switch ((c = gettoken(0, &t))) {
  80028b:	85 c0                	test   %eax,%eax
  80028d:	8d 76 00             	lea    0x0(%esi),%esi
  800290:	0f 84 4b 02 00 00    	je     8004e1 <runcmd+0x2ab>
  800296:	e9 26 02 00 00       	jmp    8004c1 <runcmd+0x28b>
  80029b:	83 f8 7c             	cmp    $0x7c,%eax
  80029e:	66 90                	xchg   %ax,%ax
  8002a0:	0f 85 1b 02 00 00    	jne    8004c1 <runcmd+0x28b>
  8002a6:	66 90                	xchg   %ax,%ax
  8002a8:	e9 27 01 00 00       	jmp    8003d4 <runcmd+0x19e>

		case 'w':	// Add an argument
			if (argc == MAXARGS) {
  8002ad:	83 fe 10             	cmp    $0x10,%esi
  8002b0:	75 11                	jne    8002c3 <runcmd+0x8d>
				cprintf("too many arguments\n");
  8002b2:	c7 04 24 97 3e 80 00 	movl   $0x803e97,(%esp)
  8002b9:	e8 07 09 00 00       	call   800bc5 <cprintf>
				exit();
  8002be:	e8 21 08 00 00       	call   800ae4 <exit>
			}
			argv[argc++] = t;
  8002c3:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  8002c6:	89 44 b5 a8          	mov    %eax,-0x58(%ebp,%esi,4)
  8002ca:	83 c6 01             	add    $0x1,%esi
			break;
  8002cd:	eb 8e                	jmp    80025d <runcmd+0x27>
			
		case '<':	// Input redirection
			// Grab the filename from the argument list
			if (gettoken(0, &t) != 'w') {
  8002cf:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8002d3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8002da:	e8 e8 fe ff ff       	call   8001c7 <gettoken>
  8002df:	83 f8 77             	cmp    $0x77,%eax
  8002e2:	74 11                	je     8002f5 <runcmd+0xbf>
				cprintf("syntax error: < not followed by word\n");
  8002e4:	c7 04 24 04 3e 80 00 	movl   $0x803e04,(%esp)
  8002eb:	e8 d5 08 00 00       	call   800bc5 <cprintf>
				exit();
  8002f0:	e8 ef 07 00 00       	call   800ae4 <exit>
			}
			if ((fd = open(t, O_RDONLY)) < 0) {
  8002f5:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8002fc:	00 
  8002fd:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  800300:	89 04 24             	mov    %eax,(%esp)
  800303:	e8 94 25 00 00       	call   80289c <open>
  800308:	89 c7                	mov    %eax,%edi
  80030a:	85 c0                	test   %eax,%eax
  80030c:	79 1e                	jns    80032c <runcmd+0xf6>
				cprintf("open %s for read: %e", t, fd);
  80030e:	89 44 24 08          	mov    %eax,0x8(%esp)
  800312:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  800315:	89 44 24 04          	mov    %eax,0x4(%esp)
  800319:	c7 04 24 ab 3e 80 00 	movl   $0x803eab,(%esp)
  800320:	e8 a0 08 00 00       	call   800bc5 <cprintf>
				exit();
  800325:	e8 ba 07 00 00       	call   800ae4 <exit>
  80032a:	eb 0a                	jmp    800336 <runcmd+0x100>
			}
			if (fd != 0) {
  80032c:	85 c0                	test   %eax,%eax
  80032e:	66 90                	xchg   %ax,%ax
  800330:	0f 84 27 ff ff ff    	je     80025d <runcmd+0x27>
				dup(fd, 0);
  800336:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80033d:	00 
  80033e:	89 3c 24             	mov    %edi,(%esp)
  800341:	e8 25 22 00 00       	call   80256b <dup>
				close(fd);
  800346:	89 3c 24             	mov    %edi,(%esp)
  800349:	e8 7e 21 00 00       	call   8024cc <close>
  80034e:	e9 0a ff ff ff       	jmp    80025d <runcmd+0x27>
			}
			break;
			
		case '>':	// Output redirection
			// Grab the filename from the argument list
			if (gettoken(0, &t) != 'w') {
  800353:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800357:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80035e:	e8 64 fe ff ff       	call   8001c7 <gettoken>
  800363:	83 f8 77             	cmp    $0x77,%eax
  800366:	74 11                	je     800379 <runcmd+0x143>
				cprintf("syntax error: > not followed by word\n");
  800368:	c7 04 24 2c 3e 80 00 	movl   $0x803e2c,(%esp)
  80036f:	e8 51 08 00 00       	call   800bc5 <cprintf>
				exit();
  800374:	e8 6b 07 00 00       	call   800ae4 <exit>
			}
			if ((fd = open(t, O_WRONLY|O_CREAT|O_TRUNC)) < 0) {
  800379:	c7 44 24 04 01 03 00 	movl   $0x301,0x4(%esp)
  800380:	00 
  800381:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  800384:	89 04 24             	mov    %eax,(%esp)
  800387:	e8 10 25 00 00       	call   80289c <open>
  80038c:	89 c7                	mov    %eax,%edi
  80038e:	85 c0                	test   %eax,%eax
  800390:	79 1c                	jns    8003ae <runcmd+0x178>
				cprintf("open %s for write: %e", t, fd);
  800392:	89 44 24 08          	mov    %eax,0x8(%esp)
  800396:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  800399:	89 44 24 04          	mov    %eax,0x4(%esp)
  80039d:	c7 04 24 c0 3e 80 00 	movl   $0x803ec0,(%esp)
  8003a4:	e8 1c 08 00 00       	call   800bc5 <cprintf>
				exit();
  8003a9:	e8 36 07 00 00       	call   800ae4 <exit>
			}
			if (fd != 1) {
  8003ae:	83 ff 01             	cmp    $0x1,%edi
  8003b1:	0f 84 a6 fe ff ff    	je     80025d <runcmd+0x27>
				dup(fd, 1);
  8003b7:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8003be:	00 
  8003bf:	89 3c 24             	mov    %edi,(%esp)
  8003c2:	e8 a4 21 00 00       	call   80256b <dup>
				close(fd);
  8003c7:	89 3c 24             	mov    %edi,(%esp)
  8003ca:	e8 fd 20 00 00       	call   8024cc <close>
  8003cf:	e9 89 fe ff ff       	jmp    80025d <runcmd+0x27>
			}
			break;
			
		case '|':	// Pipe
			if ((r = pipe(p)) < 0) {
  8003d4:	8d 85 9c fb ff ff    	lea    -0x464(%ebp),%eax
  8003da:	89 04 24             	mov    %eax,(%esp)
  8003dd:	e8 f7 33 00 00       	call   8037d9 <pipe>
  8003e2:	85 c0                	test   %eax,%eax
  8003e4:	79 15                	jns    8003fb <runcmd+0x1c5>
				cprintf("pipe: %e", r);
  8003e6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003ea:	c7 04 24 d6 3e 80 00 	movl   $0x803ed6,(%esp)
  8003f1:	e8 cf 07 00 00       	call   800bc5 <cprintf>
				exit();
  8003f6:	e8 e9 06 00 00       	call   800ae4 <exit>
			}
			if (debug)
  8003fb:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  800402:	74 20                	je     800424 <runcmd+0x1ee>
				cprintf("PIPE: %d %d\n", p[0], p[1]);
  800404:	8b 85 a0 fb ff ff    	mov    -0x460(%ebp),%eax
  80040a:	89 44 24 08          	mov    %eax,0x8(%esp)
  80040e:	8b 85 9c fb ff ff    	mov    -0x464(%ebp),%eax
  800414:	89 44 24 04          	mov    %eax,0x4(%esp)
  800418:	c7 04 24 df 3e 80 00 	movl   $0x803edf,(%esp)
  80041f:	e8 a1 07 00 00       	call   800bc5 <cprintf>
			if ((r = fork()) < 0) {
  800424:	e8 09 18 00 00       	call   801c32 <fork>
  800429:	89 c7                	mov    %eax,%edi
  80042b:	85 c0                	test   %eax,%eax
  80042d:	79 15                	jns    800444 <runcmd+0x20e>
				cprintf("fork: %e", r);
  80042f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800433:	c7 04 24 ec 3e 80 00 	movl   $0x803eec,(%esp)
  80043a:	e8 86 07 00 00       	call   800bc5 <cprintf>
				exit();
  80043f:	e8 a0 06 00 00       	call   800ae4 <exit>
			}
			if (r == 0) {
  800444:	85 ff                	test   %edi,%edi
  800446:	75 40                	jne    800488 <runcmd+0x252>
				if (p[0] != 0) {
  800448:	8b 85 9c fb ff ff    	mov    -0x464(%ebp),%eax
  80044e:	85 c0                	test   %eax,%eax
  800450:	74 1e                	je     800470 <runcmd+0x23a>
					dup(p[0], 0);
  800452:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800459:	00 
  80045a:	89 04 24             	mov    %eax,(%esp)
  80045d:	e8 09 21 00 00       	call   80256b <dup>
					close(p[0]);
  800462:	8b 85 9c fb ff ff    	mov    -0x464(%ebp),%eax
  800468:	89 04 24             	mov    %eax,(%esp)
  80046b:	e8 5c 20 00 00       	call   8024cc <close>
				}
				close(p[1]);
  800470:	8b 85 a0 fb ff ff    	mov    -0x460(%ebp),%eax
  800476:	89 04 24             	mov    %eax,(%esp)
  800479:	e8 4e 20 00 00       	call   8024cc <close>
  80047e:	be 00 00 00 00       	mov    $0x0,%esi
  800483:	e9 d5 fd ff ff       	jmp    80025d <runcmd+0x27>
				goto again;
			} else {
				pipe_child = r;
				if (p[1] != 1) {
  800488:	8b 85 a0 fb ff ff    	mov    -0x460(%ebp),%eax
  80048e:	83 f8 01             	cmp    $0x1,%eax
  800491:	74 1e                	je     8004b1 <runcmd+0x27b>
					dup(p[1], 1);
  800493:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  80049a:	00 
  80049b:	89 04 24             	mov    %eax,(%esp)
  80049e:	e8 c8 20 00 00       	call   80256b <dup>
					close(p[1]);
  8004a3:	8b 85 a0 fb ff ff    	mov    -0x460(%ebp),%eax
  8004a9:	89 04 24             	mov    %eax,(%esp)
  8004ac:	e8 1b 20 00 00       	call   8024cc <close>
				}
				close(p[0]);
  8004b1:	8b 85 9c fb ff ff    	mov    -0x464(%ebp),%eax
  8004b7:	89 04 24             	mov    %eax,(%esp)
  8004ba:	e8 0d 20 00 00       	call   8024cc <close>
				goto runit;
  8004bf:	eb 20                	jmp    8004e1 <runcmd+0x2ab>
		case 0:		// String is complete
			// Run the current command!
			goto runit;
			
		default:
			panic("bad return %d from gettoken", c);
  8004c1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8004c5:	c7 44 24 08 f5 3e 80 	movl   $0x803ef5,0x8(%esp)
  8004cc:	00 
  8004cd:	c7 44 24 04 6e 00 00 	movl   $0x6e,0x4(%esp)
  8004d4:	00 
  8004d5:	c7 04 24 11 3f 80 00 	movl   $0x803f11,(%esp)
  8004dc:	e8 1f 06 00 00       	call   800b00 <_panic>
		}
	}

runit:
	// Return immediately if command line was empty.
	if(argc == 0) {
  8004e1:	85 f6                	test   %esi,%esi
  8004e3:	75 1e                	jne    800503 <runcmd+0x2cd>
		if (debug)
  8004e5:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  8004ec:	0f 84 7f 01 00 00    	je     800671 <runcmd+0x43b>
			cprintf("EMPTY COMMAND\n");
  8004f2:	c7 04 24 1b 3f 80 00 	movl   $0x803f1b,(%esp)
  8004f9:	e8 c7 06 00 00       	call   800bc5 <cprintf>
  8004fe:	e9 6e 01 00 00       	jmp    800671 <runcmd+0x43b>

	// Clean up command line.
	// Read all commands from the filesystem: add an initial '/' to
	// the command name.
	// This essentially acts like 'PATH=/'.
	if (argv[0][0] != '/') {
  800503:	8b 45 a8             	mov    -0x58(%ebp),%eax
  800506:	80 38 2f             	cmpb   $0x2f,(%eax)
  800509:	74 22                	je     80052d <runcmd+0x2f7>
		argv0buf[0] = '/';
  80050b:	c6 85 a4 fb ff ff 2f 	movb   $0x2f,-0x45c(%ebp)
		strcpy(argv0buf + 1, argv[0]);
  800512:	89 44 24 04          	mov    %eax,0x4(%esp)
  800516:	8d 9d a4 fb ff ff    	lea    -0x45c(%ebp),%ebx
  80051c:	8d 85 a5 fb ff ff    	lea    -0x45b(%ebp),%eax
  800522:	89 04 24             	mov    %eax,(%esp)
  800525:	e8 60 0e 00 00       	call   80138a <strcpy>
		argv[0] = argv0buf;
  80052a:	89 5d a8             	mov    %ebx,-0x58(%ebp)
	}
	argv[argc] = 0;
  80052d:	c7 44 b5 a8 00 00 00 	movl   $0x0,-0x58(%ebp,%esi,4)
  800534:	00 
	
	// Print the command.
	if (debug) {
  800535:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  80053c:	74 47                	je     800585 <runcmd+0x34f>
		cprintf("[%08x] SPAWN:", env->env_id);
  80053e:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  800543:	8b 40 4c             	mov    0x4c(%eax),%eax
  800546:	89 44 24 04          	mov    %eax,0x4(%esp)
  80054a:	c7 04 24 2a 3f 80 00 	movl   $0x803f2a,(%esp)
  800551:	e8 6f 06 00 00       	call   800bc5 <cprintf>
		for (i = 0; argv[i]; i++)
  800556:	8b 45 a8             	mov    -0x58(%ebp),%eax
  800559:	85 c0                	test   %eax,%eax
  80055b:	74 1c                	je     800579 <runcmd+0x343>
  80055d:	8d 5d ac             	lea    -0x54(%ebp),%ebx
			cprintf(" %s", argv[i]);
  800560:	89 44 24 04          	mov    %eax,0x4(%esp)
  800564:	c7 04 24 b2 3f 80 00 	movl   $0x803fb2,(%esp)
  80056b:	e8 55 06 00 00       	call   800bc5 <cprintf>
	argv[argc] = 0;
	
	// Print the command.
	if (debug) {
		cprintf("[%08x] SPAWN:", env->env_id);
		for (i = 0; argv[i]; i++)
  800570:	8b 03                	mov    (%ebx),%eax
  800572:	83 c3 04             	add    $0x4,%ebx
  800575:	85 c0                	test   %eax,%eax
  800577:	75 e7                	jne    800560 <runcmd+0x32a>
			cprintf(" %s", argv[i]);
		cprintf("\n");
  800579:	c7 04 24 72 3e 80 00 	movl   $0x803e72,(%esp)
  800580:	e8 40 06 00 00       	call   800bc5 <cprintf>
	}

	// Spawn the command!
	if ((r = spawn(argv[0], (const char**) argv)) < 0)
  800585:	8d 45 a8             	lea    -0x58(%ebp),%eax
  800588:	89 44 24 04          	mov    %eax,0x4(%esp)
  80058c:	8b 45 a8             	mov    -0x58(%ebp),%eax
  80058f:	89 04 24             	mov    %eax,(%esp)
  800592:	e8 c9 24 00 00       	call   802a60 <spawn>
  800597:	89 c3                	mov    %eax,%ebx
  800599:	85 c0                	test   %eax,%eax
  80059b:	79 1e                	jns    8005bb <runcmd+0x385>
		cprintf("spawn %s: %e\n", argv[0], r);
  80059d:	89 44 24 08          	mov    %eax,0x8(%esp)
  8005a1:	8b 45 a8             	mov    -0x58(%ebp),%eax
  8005a4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8005a8:	c7 04 24 38 3f 80 00 	movl   $0x803f38,(%esp)
  8005af:	e8 11 06 00 00       	call   800bc5 <cprintf>

	// In the parent, close all file descriptors and wait for the
	// spawned command to exit.
	close_all();
  8005b4:	e8 90 1f 00 00       	call   802549 <close_all>
  8005b9:	eb 5f                	jmp    80061a <runcmd+0x3e4>
  8005bb:	90                   	nop
  8005bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8005c0:	e8 84 1f 00 00       	call   802549 <close_all>
	if (r >= 0) {
		if (debug)
  8005c5:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  8005cc:	74 23                	je     8005f1 <runcmd+0x3bb>
			cprintf("[%08x] WAIT %s %08x\n", env->env_id, argv[0], r);
  8005ce:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  8005d3:	8b 40 4c             	mov    0x4c(%eax),%eax
  8005d6:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8005da:	8b 55 a8             	mov    -0x58(%ebp),%edx
  8005dd:	89 54 24 08          	mov    %edx,0x8(%esp)
  8005e1:	89 44 24 04          	mov    %eax,0x4(%esp)
  8005e5:	c7 04 24 46 3f 80 00 	movl   $0x803f46,(%esp)
  8005ec:	e8 d4 05 00 00       	call   800bc5 <cprintf>
		wait(r);
  8005f1:	89 1c 24             	mov    %ebx,(%esp)
  8005f4:	e8 5b 33 00 00       	call   803954 <wait>
		if (debug)
  8005f9:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  800600:	74 18                	je     80061a <runcmd+0x3e4>
			cprintf("[%08x] wait finished\n", env->env_id);
  800602:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  800607:	8b 40 4c             	mov    0x4c(%eax),%eax
  80060a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80060e:	c7 04 24 5b 3f 80 00 	movl   $0x803f5b,(%esp)
  800615:	e8 ab 05 00 00       	call   800bc5 <cprintf>
	}

	// If we were the left-hand part of a pipe,
	// wait for the right-hand part to finish.
	if (pipe_child) {
  80061a:	85 ff                	test   %edi,%edi
  80061c:	74 4e                	je     80066c <runcmd+0x436>
		if (debug)
  80061e:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  800625:	74 1c                	je     800643 <runcmd+0x40d>
			cprintf("[%08x] WAIT pipe_child %08x\n", env->env_id, pipe_child);
  800627:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  80062c:	8b 40 4c             	mov    0x4c(%eax),%eax
  80062f:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800633:	89 44 24 04          	mov    %eax,0x4(%esp)
  800637:	c7 04 24 71 3f 80 00 	movl   $0x803f71,(%esp)
  80063e:	e8 82 05 00 00       	call   800bc5 <cprintf>
		wait(pipe_child);
  800643:	89 3c 24             	mov    %edi,(%esp)
  800646:	e8 09 33 00 00       	call   803954 <wait>
		if (debug)
  80064b:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  800652:	74 18                	je     80066c <runcmd+0x436>
			cprintf("[%08x] wait finished\n", env->env_id);
  800654:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  800659:	8b 40 4c             	mov    0x4c(%eax),%eax
  80065c:	89 44 24 04          	mov    %eax,0x4(%esp)
  800660:	c7 04 24 5b 3f 80 00 	movl   $0x803f5b,(%esp)
  800667:	e8 59 05 00 00       	call   800bc5 <cprintf>
	}

	// Done!
	exit();
  80066c:	e8 73 04 00 00       	call   800ae4 <exit>
}
  800671:	81 c4 6c 04 00 00    	add    $0x46c,%esp
  800677:	5b                   	pop    %ebx
  800678:	5e                   	pop    %esi
  800679:	5f                   	pop    %edi
  80067a:	5d                   	pop    %ebp
  80067b:	c3                   	ret    

0080067c <umain>:
	exit();
}

void
umain(int argc, char **argv)
{
  80067c:	55                   	push   %ebp
  80067d:	89 e5                	mov    %esp,%ebp
  80067f:	57                   	push   %edi
  800680:	56                   	push   %esi
  800681:	53                   	push   %ebx
  800682:	83 ec 3c             	sub    $0x3c,%esp
  800685:	8b 45 0c             	mov    0xc(%ebp),%eax
	int r, interactive, echocmds;

	interactive = '?';
	echocmds = 0;
	ARGBEGIN{
  800688:	85 c0                	test   %eax,%eax
  80068a:	8d 55 08             	lea    0x8(%ebp),%edx
  80068d:	0f 44 c2             	cmove  %edx,%eax
  800690:	83 3d a4 84 80 00 00 	cmpl   $0x0,0x8084a4
  800697:	75 08                	jne    8006a1 <umain+0x25>
  800699:	8b 10                	mov    (%eax),%edx
  80069b:	89 15 a4 84 80 00    	mov    %edx,0x8084a4
  8006a1:	83 c0 04             	add    $0x4,%eax
  8006a4:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8006a7:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  8006ab:	8b 18                	mov    (%eax),%ebx
  8006ad:	85 db                	test   %ebx,%ebx
  8006af:	0f 84 97 00 00 00    	je     80074c <umain+0xd0>
  8006b5:	80 3b 2d             	cmpb   $0x2d,(%ebx)
  8006b8:	0f 85 8e 00 00 00    	jne    80074c <umain+0xd0>
  8006be:	83 c3 01             	add    $0x1,%ebx
  8006c1:	0f b6 03             	movzbl (%ebx),%eax
  8006c4:	84 c0                	test   %al,%al
  8006c6:	0f 84 80 00 00 00    	je     80074c <umain+0xd0>
  8006cc:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8006d3:	bf 3f 00 00 00       	mov    $0x3f,%edi
  8006d8:	be 01 00 00 00       	mov    $0x1,%esi
  8006dd:	3c 2d                	cmp    $0x2d,%al
  8006df:	75 21                	jne    800702 <umain+0x86>
  8006e1:	80 7b 01 00          	cmpb   $0x0,0x1(%ebx)
  8006e5:	75 1b                	jne    800702 <umain+0x86>
  8006e7:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  8006eb:	83 45 e0 04          	addl   $0x4,-0x20(%ebp)
  8006ef:	eb 67                	jmp    800758 <umain+0xdc>
	case 'd':
		debug++;
  8006f1:	83 05 80 80 80 00 01 	addl   $0x1,0x808080
		break;
  8006f8:	eb 05                	jmp    8006ff <umain+0x83>
		break;
	case 'x':
		echocmds = 1;
		break;
	default:
		usage();
  8006fa:	e8 41 f9 ff ff       	call   800040 <usage>
{
	int r, interactive, echocmds;

	interactive = '?';
	echocmds = 0;
	ARGBEGIN{
  8006ff:	83 c3 01             	add    $0x1,%ebx
  800702:	0f b6 03             	movzbl (%ebx),%eax
  800705:	84 c0                	test   %al,%al
  800707:	74 21                	je     80072a <umain+0xae>
  800709:	3c 69                	cmp    $0x69,%al
  80070b:	74 15                	je     800722 <umain+0xa6>
  80070d:	3c 78                	cmp    $0x78,%al
  80070f:	74 09                	je     80071a <umain+0x9e>
  800711:	3c 64                	cmp    $0x64,%al
  800713:	75 e5                	jne    8006fa <umain+0x7e>
  800715:	8d 76 00             	lea    0x0(%esi),%esi
  800718:	eb d7                	jmp    8006f1 <umain+0x75>
  80071a:	89 75 e4             	mov    %esi,-0x1c(%ebp)
  80071d:	8d 76 00             	lea    0x0(%esi),%esi
  800720:	eb dd                	jmp    8006ff <umain+0x83>
  800722:	89 f7                	mov    %esi,%edi
  800724:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800728:	eb d5                	jmp    8006ff <umain+0x83>
  80072a:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  80072e:	83 45 e0 04          	addl   $0x4,-0x20(%ebp)
  800732:	8b 45 e0             	mov    -0x20(%ebp),%eax
  800735:	8b 18                	mov    (%eax),%ebx
  800737:	85 db                	test   %ebx,%ebx
  800739:	74 1d                	je     800758 <umain+0xdc>
  80073b:	80 3b 2d             	cmpb   $0x2d,(%ebx)
  80073e:	75 18                	jne    800758 <umain+0xdc>
  800740:	83 c3 01             	add    $0x1,%ebx
  800743:	0f b6 03             	movzbl (%ebx),%eax
  800746:	84 c0                	test   %al,%al
  800748:	75 93                	jne    8006dd <umain+0x61>
  80074a:	eb 0c                	jmp    800758 <umain+0xdc>
  80074c:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800753:	bf 3f 00 00 00       	mov    $0x3f,%edi
		break;
	default:
		usage();
	}ARGEND

	if (argc > 1)
  800758:	83 7d 08 01          	cmpl   $0x1,0x8(%ebp)
  80075c:	7e 07                	jle    800765 <umain+0xe9>
		usage();
  80075e:	66 90                	xchg   %ax,%ax
  800760:	e8 db f8 ff ff       	call   800040 <usage>
	if (argc == 1) {
  800765:	83 7d 08 01          	cmpl   $0x1,0x8(%ebp)
  800769:	75 76                	jne    8007e1 <umain+0x165>
		close(0);
  80076b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800772:	e8 55 1d 00 00       	call   8024cc <close>
		if ((r = open(argv[0], O_RDONLY)) < 0)
  800777:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80077e:	00 
  80077f:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800782:	8b 02                	mov    (%edx),%eax
  800784:	89 04 24             	mov    %eax,(%esp)
  800787:	e8 10 21 00 00       	call   80289c <open>
  80078c:	85 c0                	test   %eax,%eax
  80078e:	79 29                	jns    8007b9 <umain+0x13d>
			panic("open %s: %e", argv[0], r);
  800790:	89 44 24 10          	mov    %eax,0x10(%esp)
  800794:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800797:	8b 02                	mov    (%edx),%eax
  800799:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80079d:	c7 44 24 08 8e 3f 80 	movl   $0x803f8e,0x8(%esp)
  8007a4:	00 
  8007a5:	c7 44 24 04 1b 01 00 	movl   $0x11b,0x4(%esp)
  8007ac:	00 
  8007ad:	c7 04 24 11 3f 80 00 	movl   $0x803f11,(%esp)
  8007b4:	e8 47 03 00 00       	call   800b00 <_panic>
		assert(r == 0);
  8007b9:	85 c0                	test   %eax,%eax
  8007bb:	74 24                	je     8007e1 <umain+0x165>
  8007bd:	c7 44 24 0c 9a 3f 80 	movl   $0x803f9a,0xc(%esp)
  8007c4:	00 
  8007c5:	c7 44 24 08 a1 3f 80 	movl   $0x803fa1,0x8(%esp)
  8007cc:	00 
  8007cd:	c7 44 24 04 1c 01 00 	movl   $0x11c,0x4(%esp)
  8007d4:	00 
  8007d5:	c7 04 24 11 3f 80 00 	movl   $0x803f11,(%esp)
  8007dc:	e8 1f 03 00 00       	call   800b00 <_panic>
	}
	if (interactive == '?')
  8007e1:	83 ff 3f             	cmp    $0x3f,%edi
  8007e4:	75 0e                	jne    8007f4 <umain+0x178>
		interactive = iscons(0);
  8007e6:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8007ed:	e8 3b 02 00 00       	call   800a2d <iscons>
  8007f2:	89 c7                	mov    %eax,%edi
	
	while (1) {
		char *buf;

		buf = readline(interactive ? "$ " : NULL);
  8007f4:	85 ff                	test   %edi,%edi
  8007f6:	b8 00 00 00 00       	mov    $0x0,%eax
  8007fb:	ba b6 3f 80 00       	mov    $0x803fb6,%edx
  800800:	0f 45 c2             	cmovne %edx,%eax
  800803:	89 04 24             	mov    %eax,(%esp)
  800806:	e8 45 0a 00 00       	call   801250 <readline>
  80080b:	89 c3                	mov    %eax,%ebx
		if (buf == NULL) {
  80080d:	85 c0                	test   %eax,%eax
  80080f:	75 1a                	jne    80082b <umain+0x1af>
			if (debug)
  800811:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  800818:	74 0c                	je     800826 <umain+0x1aa>
				cprintf("EXITING\n");
  80081a:	c7 04 24 b9 3f 80 00 	movl   $0x803fb9,(%esp)
  800821:	e8 9f 03 00 00       	call   800bc5 <cprintf>
			exit();	// end of file
  800826:	e8 b9 02 00 00       	call   800ae4 <exit>
		}
		if (debug)
  80082b:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  800832:	74 10                	je     800844 <umain+0x1c8>
			cprintf("LINE: %s\n", buf);
  800834:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800838:	c7 04 24 c2 3f 80 00 	movl   $0x803fc2,(%esp)
  80083f:	e8 81 03 00 00       	call   800bc5 <cprintf>
		if (buf[0] == '#')
  800844:	80 3b 23             	cmpb   $0x23,(%ebx)
  800847:	74 ab                	je     8007f4 <umain+0x178>
			continue;
		if (echocmds)
  800849:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80084d:	74 10                	je     80085f <umain+0x1e3>
			printf("# %s\n", buf);
  80084f:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800853:	c7 04 24 cc 3f 80 00 	movl   $0x803fcc,(%esp)
  80085a:	e8 88 21 00 00       	call   8029e7 <printf>
		if (debug)
  80085f:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  800866:	74 0c                	je     800874 <umain+0x1f8>
			cprintf("BEFORE FORK\n");
  800868:	c7 04 24 d2 3f 80 00 	movl   $0x803fd2,(%esp)
  80086f:	e8 51 03 00 00       	call   800bc5 <cprintf>
		if ((r = fork()) < 0)
  800874:	e8 b9 13 00 00       	call   801c32 <fork>
  800879:	89 c6                	mov    %eax,%esi
  80087b:	85 c0                	test   %eax,%eax
  80087d:	79 20                	jns    80089f <umain+0x223>
			panic("fork: %e", r);
  80087f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800883:	c7 44 24 08 ec 3e 80 	movl   $0x803eec,0x8(%esp)
  80088a:	00 
  80088b:	c7 44 24 04 33 01 00 	movl   $0x133,0x4(%esp)
  800892:	00 
  800893:	c7 04 24 11 3f 80 00 	movl   $0x803f11,(%esp)
  80089a:	e8 61 02 00 00       	call   800b00 <_panic>
		if (debug)
  80089f:	83 3d 80 80 80 00 00 	cmpl   $0x0,0x808080
  8008a6:	74 10                	je     8008b8 <umain+0x23c>
			cprintf("FORK: %d\n", r);
  8008a8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8008ac:	c7 04 24 df 3f 80 00 	movl   $0x803fdf,(%esp)
  8008b3:	e8 0d 03 00 00       	call   800bc5 <cprintf>
		if (r == 0) {
  8008b8:	85 f6                	test   %esi,%esi
  8008ba:	75 12                	jne    8008ce <umain+0x252>
			runcmd(buf);
  8008bc:	89 1c 24             	mov    %ebx,(%esp)
  8008bf:	e8 72 f9 ff ff       	call   800236 <runcmd>
			exit();
  8008c4:	e8 1b 02 00 00       	call   800ae4 <exit>
  8008c9:	e9 26 ff ff ff       	jmp    8007f4 <umain+0x178>
		} else
			wait(r);
  8008ce:	89 34 24             	mov    %esi,(%esp)
  8008d1:	e8 7e 30 00 00       	call   803954 <wait>
  8008d6:	e9 19 ff ff ff       	jmp    8007f4 <umain+0x178>
  8008db:	00 00                	add    %al,(%eax)
  8008dd:	00 00                	add    %al,(%eax)
	...

008008e0 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  8008e0:	55                   	push   %ebp
  8008e1:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  8008e3:	b8 00 00 00 00       	mov    $0x0,%eax
  8008e8:	5d                   	pop    %ebp
  8008e9:	c3                   	ret    

008008ea <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  8008ea:	55                   	push   %ebp
  8008eb:	89 e5                	mov    %esp,%ebp
  8008ed:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  8008f0:	c7 44 24 04 e9 3f 80 	movl   $0x803fe9,0x4(%esp)
  8008f7:	00 
  8008f8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8008fb:	89 04 24             	mov    %eax,(%esp)
  8008fe:	e8 87 0a 00 00       	call   80138a <strcpy>
	return 0;
}
  800903:	b8 00 00 00 00       	mov    $0x0,%eax
  800908:	c9                   	leave  
  800909:	c3                   	ret    

0080090a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80090a:	55                   	push   %ebp
  80090b:	89 e5                	mov    %esp,%ebp
  80090d:	57                   	push   %edi
  80090e:	56                   	push   %esi
  80090f:	53                   	push   %ebx
  800910:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  800916:	b8 00 00 00 00       	mov    $0x0,%eax
  80091b:	be 00 00 00 00       	mov    $0x0,%esi
  800920:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  800924:	74 41                	je     800967 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  800926:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80092c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80092f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  800931:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  800937:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80093c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80093f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800943:	03 45 0c             	add    0xc(%ebp),%eax
  800946:	89 44 24 04          	mov    %eax,0x4(%esp)
  80094a:	89 3c 24             	mov    %edi,(%esp)
  80094d:	e8 f3 0b 00 00       	call   801545 <memmove>
		sys_cputs(buf, m);
  800952:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800956:	89 3c 24             	mov    %edi,(%esp)
  800959:	e8 22 0e 00 00       	call   801780 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  80095e:	01 de                	add    %ebx,%esi
  800960:	89 f0                	mov    %esi,%eax
  800962:	3b 75 10             	cmp    0x10(%ebp),%esi
  800965:	72 c5                	jb     80092c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  800967:	89 f0                	mov    %esi,%eax
  800969:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  80096f:	5b                   	pop    %ebx
  800970:	5e                   	pop    %esi
  800971:	5f                   	pop    %edi
  800972:	5d                   	pop    %ebp
  800973:	c3                   	ret    

00800974 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  800974:	55                   	push   %ebp
  800975:	89 e5                	mov    %esp,%ebp
  800977:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  80097a:	8b 45 08             	mov    0x8(%ebp),%eax
  80097d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  800980:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  800987:	00 
  800988:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80098b:	89 04 24             	mov    %eax,(%esp)
  80098e:	e8 ed 0d 00 00       	call   801780 <sys_cputs>
}
  800993:	c9                   	leave  
  800994:	c3                   	ret    

00800995 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  800995:	55                   	push   %ebp
  800996:	89 e5                	mov    %esp,%ebp
  800998:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  80099b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80099f:	75 07                	jne    8009a8 <devcons_read+0x13>
  8009a1:	eb 2d                	jmp    8009d0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8009a3:	e8 9d 11 00 00       	call   801b45 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8009a8:	90                   	nop
  8009a9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8009b0:	e8 97 0d 00 00       	call   80174c <sys_cgetc>
  8009b5:	85 c0                	test   %eax,%eax
  8009b7:	74 ea                	je     8009a3 <devcons_read+0xe>
  8009b9:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  8009bb:	85 c0                	test   %eax,%eax
  8009bd:	78 16                	js     8009d5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  8009bf:	83 f8 04             	cmp    $0x4,%eax
  8009c2:	74 0c                	je     8009d0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  8009c4:	8b 45 0c             	mov    0xc(%ebp),%eax
  8009c7:	88 10                	mov    %dl,(%eax)
  8009c9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  8009ce:	eb 05                	jmp    8009d5 <devcons_read+0x40>
  8009d0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8009d5:	c9                   	leave  
  8009d6:	c3                   	ret    

008009d7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  8009d7:	55                   	push   %ebp
  8009d8:	89 e5                	mov    %esp,%ebp
  8009da:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  8009dd:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8009e0:	89 04 24             	mov    %eax,(%esp)
  8009e3:	e8 53 16 00 00       	call   80203b <fd_alloc>
  8009e8:	85 c0                	test   %eax,%eax
  8009ea:	78 3f                	js     800a2b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  8009ec:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8009f3:	00 
  8009f4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8009f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8009fb:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800a02:	e8 df 10 00 00       	call   801ae6 <sys_page_alloc>
  800a07:	85 c0                	test   %eax,%eax
  800a09:	78 20                	js     800a2b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  800a0b:	8b 15 00 80 80 00    	mov    0x808000,%edx
  800a11:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800a14:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  800a16:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800a19:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  800a20:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800a23:	89 04 24             	mov    %eax,(%esp)
  800a26:	e8 e5 15 00 00       	call   802010 <fd2num>
}
  800a2b:	c9                   	leave  
  800a2c:	c3                   	ret    

00800a2d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  800a2d:	55                   	push   %ebp
  800a2e:	89 e5                	mov    %esp,%ebp
  800a30:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  800a33:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800a36:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a3a:	8b 45 08             	mov    0x8(%ebp),%eax
  800a3d:	89 04 24             	mov    %eax,(%esp)
  800a40:	e8 68 16 00 00       	call   8020ad <fd_lookup>
  800a45:	85 c0                	test   %eax,%eax
  800a47:	78 11                	js     800a5a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  800a49:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800a4c:	8b 00                	mov    (%eax),%eax
  800a4e:	3b 05 00 80 80 00    	cmp    0x808000,%eax
  800a54:	0f 94 c0             	sete   %al
  800a57:	0f b6 c0             	movzbl %al,%eax
}
  800a5a:	c9                   	leave  
  800a5b:	c3                   	ret    

00800a5c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  800a5c:	55                   	push   %ebp
  800a5d:	89 e5                	mov    %esp,%ebp
  800a5f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  800a62:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  800a69:	00 
  800a6a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  800a6d:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a71:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800a78:	e8 96 18 00 00       	call   802313 <read>
	if (r < 0)
  800a7d:	85 c0                	test   %eax,%eax
  800a7f:	78 0f                	js     800a90 <getchar+0x34>
		return r;
	if (r < 1)
  800a81:	85 c0                	test   %eax,%eax
  800a83:	7f 07                	jg     800a8c <getchar+0x30>
  800a85:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  800a8a:	eb 04                	jmp    800a90 <getchar+0x34>
		return -E_EOF;
	return c;
  800a8c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  800a90:	c9                   	leave  
  800a91:	c3                   	ret    
	...

00800a94 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800a94:	55                   	push   %ebp
  800a95:	89 e5                	mov    %esp,%ebp
  800a97:	83 ec 18             	sub    $0x18,%esp
  800a9a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800a9d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800aa0:	8b 75 08             	mov    0x8(%ebp),%esi
  800aa3:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  800aa6:	e8 ce 10 00 00       	call   801b79 <sys_getenvid>
	env = &envs [ENVX(envid)];
  800aab:	25 ff 03 00 00       	and    $0x3ff,%eax
  800ab0:	6b c0 7c             	imul   $0x7c,%eax,%eax
  800ab3:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800ab8:	a3 a0 84 80 00       	mov    %eax,0x8084a0

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800abd:	85 f6                	test   %esi,%esi
  800abf:	7e 07                	jle    800ac8 <libmain+0x34>
		binaryname = argv[0];
  800ac1:	8b 03                	mov    (%ebx),%eax
  800ac3:	a3 1c 80 80 00       	mov    %eax,0x80801c

	// call user main routine
	umain(argc, argv);
  800ac8:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800acc:	89 34 24             	mov    %esi,(%esp)
  800acf:	e8 a8 fb ff ff       	call   80067c <umain>

	// exit gracefully
	exit();
  800ad4:	e8 0b 00 00 00       	call   800ae4 <exit>
}
  800ad9:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800adc:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800adf:	89 ec                	mov    %ebp,%esp
  800ae1:	5d                   	pop    %ebp
  800ae2:	c3                   	ret    
	...

00800ae4 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800ae4:	55                   	push   %ebp
  800ae5:	89 e5                	mov    %esp,%ebp
  800ae7:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800aea:	e8 5a 1a 00 00       	call   802549 <close_all>
	sys_env_destroy(0);
  800aef:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800af6:	e8 b2 10 00 00       	call   801bad <sys_env_destroy>
}
  800afb:	c9                   	leave  
  800afc:	c3                   	ret    
  800afd:	00 00                	add    %al,(%eax)
	...

00800b00 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  800b00:	55                   	push   %ebp
  800b01:	89 e5                	mov    %esp,%ebp
  800b03:	53                   	push   %ebx
  800b04:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800b07:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  800b0a:	a1 a4 84 80 00       	mov    0x8084a4,%eax
  800b0f:	85 c0                	test   %eax,%eax
  800b11:	74 10                	je     800b23 <_panic+0x23>
		cprintf("%s: ", argv0);
  800b13:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b17:	c7 04 24 0c 40 80 00 	movl   $0x80400c,(%esp)
  800b1e:	e8 a2 00 00 00       	call   800bc5 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  800b23:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b26:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b2a:	8b 45 08             	mov    0x8(%ebp),%eax
  800b2d:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b31:	a1 1c 80 80 00       	mov    0x80801c,%eax
  800b36:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b3a:	c7 04 24 11 40 80 00 	movl   $0x804011,(%esp)
  800b41:	e8 7f 00 00 00       	call   800bc5 <cprintf>
	vcprintf(fmt, ap);
  800b46:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800b4a:	8b 45 10             	mov    0x10(%ebp),%eax
  800b4d:	89 04 24             	mov    %eax,(%esp)
  800b50:	e8 0f 00 00 00       	call   800b64 <vcprintf>
	cprintf("\n");
  800b55:	c7 04 24 72 3e 80 00 	movl   $0x803e72,(%esp)
  800b5c:	e8 64 00 00 00       	call   800bc5 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800b61:	cc                   	int3   
  800b62:	eb fd                	jmp    800b61 <_panic+0x61>

00800b64 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800b64:	55                   	push   %ebp
  800b65:	89 e5                	mov    %esp,%ebp
  800b67:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  800b6d:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800b74:	00 00 00 
	b.cnt = 0;
  800b77:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  800b7e:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800b81:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b84:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b88:	8b 45 08             	mov    0x8(%ebp),%eax
  800b8b:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b8f:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800b95:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b99:	c7 04 24 df 0b 80 00 	movl   $0x800bdf,(%esp)
  800ba0:	e8 d8 01 00 00       	call   800d7d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800ba5:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  800bab:	89 44 24 04          	mov    %eax,0x4(%esp)
  800baf:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800bb5:	89 04 24             	mov    %eax,(%esp)
  800bb8:	e8 c3 0b 00 00       	call   801780 <sys_cputs>

	return b.cnt;
}
  800bbd:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  800bc3:	c9                   	leave  
  800bc4:	c3                   	ret    

00800bc5 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800bc5:	55                   	push   %ebp
  800bc6:	89 e5                	mov    %esp,%ebp
  800bc8:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800bcb:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  800bce:	89 44 24 04          	mov    %eax,0x4(%esp)
  800bd2:	8b 45 08             	mov    0x8(%ebp),%eax
  800bd5:	89 04 24             	mov    %eax,(%esp)
  800bd8:	e8 87 ff ff ff       	call   800b64 <vcprintf>
	va_end(ap);

	return cnt;
}
  800bdd:	c9                   	leave  
  800bde:	c3                   	ret    

00800bdf <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  800bdf:	55                   	push   %ebp
  800be0:	89 e5                	mov    %esp,%ebp
  800be2:	53                   	push   %ebx
  800be3:	83 ec 14             	sub    $0x14,%esp
  800be6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800be9:	8b 03                	mov    (%ebx),%eax
  800beb:	8b 55 08             	mov    0x8(%ebp),%edx
  800bee:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  800bf2:	83 c0 01             	add    $0x1,%eax
  800bf5:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800bf7:	3d ff 00 00 00       	cmp    $0xff,%eax
  800bfc:	75 19                	jne    800c17 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  800bfe:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800c05:	00 
  800c06:	8d 43 08             	lea    0x8(%ebx),%eax
  800c09:	89 04 24             	mov    %eax,(%esp)
  800c0c:	e8 6f 0b 00 00       	call   801780 <sys_cputs>
		b->idx = 0;
  800c11:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800c17:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  800c1b:	83 c4 14             	add    $0x14,%esp
  800c1e:	5b                   	pop    %ebx
  800c1f:	5d                   	pop    %ebp
  800c20:	c3                   	ret    
	...

00800c30 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800c30:	55                   	push   %ebp
  800c31:	89 e5                	mov    %esp,%ebp
  800c33:	57                   	push   %edi
  800c34:	56                   	push   %esi
  800c35:	53                   	push   %ebx
  800c36:	83 ec 4c             	sub    $0x4c,%esp
  800c39:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800c3c:	89 d6                	mov    %edx,%esi
  800c3e:	8b 45 08             	mov    0x8(%ebp),%eax
  800c41:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800c44:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c47:	89 55 e0             	mov    %edx,-0x20(%ebp)
  800c4a:	8b 45 10             	mov    0x10(%ebp),%eax
  800c4d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800c50:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800c53:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800c56:	b9 00 00 00 00       	mov    $0x0,%ecx
  800c5b:	39 d1                	cmp    %edx,%ecx
  800c5d:	72 15                	jb     800c74 <printnum+0x44>
  800c5f:	77 07                	ja     800c68 <printnum+0x38>
  800c61:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800c64:	39 d0                	cmp    %edx,%eax
  800c66:	76 0c                	jbe    800c74 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800c68:	83 eb 01             	sub    $0x1,%ebx
  800c6b:	85 db                	test   %ebx,%ebx
  800c6d:	8d 76 00             	lea    0x0(%esi),%esi
  800c70:	7f 61                	jg     800cd3 <printnum+0xa3>
  800c72:	eb 70                	jmp    800ce4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800c74:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800c78:	83 eb 01             	sub    $0x1,%ebx
  800c7b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800c7f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800c83:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800c87:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  800c8b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800c8e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800c91:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800c94:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800c98:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  800c9f:	00 
  800ca0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800ca3:	89 04 24             	mov    %eax,(%esp)
  800ca6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800ca9:	89 54 24 04          	mov    %edx,0x4(%esp)
  800cad:	e8 be 2e 00 00       	call   803b70 <__udivdi3>
  800cb2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800cb5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800cb8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  800cbc:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800cc0:	89 04 24             	mov    %eax,(%esp)
  800cc3:	89 54 24 04          	mov    %edx,0x4(%esp)
  800cc7:	89 f2                	mov    %esi,%edx
  800cc9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800ccc:	e8 5f ff ff ff       	call   800c30 <printnum>
  800cd1:	eb 11                	jmp    800ce4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800cd3:	89 74 24 04          	mov    %esi,0x4(%esp)
  800cd7:	89 3c 24             	mov    %edi,(%esp)
  800cda:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800cdd:	83 eb 01             	sub    $0x1,%ebx
  800ce0:	85 db                	test   %ebx,%ebx
  800ce2:	7f ef                	jg     800cd3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800ce4:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ce8:	8b 74 24 04          	mov    0x4(%esp),%esi
  800cec:	8b 45 dc             	mov    -0x24(%ebp),%eax
  800cef:	89 44 24 08          	mov    %eax,0x8(%esp)
  800cf3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  800cfa:	00 
  800cfb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800cfe:	89 14 24             	mov    %edx,(%esp)
  800d01:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800d04:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800d08:	e8 93 2f 00 00       	call   803ca0 <__umoddi3>
  800d0d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d11:	0f be 80 2d 40 80 00 	movsbl 0x80402d(%eax),%eax
  800d18:	89 04 24             	mov    %eax,(%esp)
  800d1b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  800d1e:	83 c4 4c             	add    $0x4c,%esp
  800d21:	5b                   	pop    %ebx
  800d22:	5e                   	pop    %esi
  800d23:	5f                   	pop    %edi
  800d24:	5d                   	pop    %ebp
  800d25:	c3                   	ret    

00800d26 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800d26:	55                   	push   %ebp
  800d27:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800d29:	83 fa 01             	cmp    $0x1,%edx
  800d2c:	7e 0e                	jle    800d3c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  800d2e:	8b 10                	mov    (%eax),%edx
  800d30:	8d 4a 08             	lea    0x8(%edx),%ecx
  800d33:	89 08                	mov    %ecx,(%eax)
  800d35:	8b 02                	mov    (%edx),%eax
  800d37:	8b 52 04             	mov    0x4(%edx),%edx
  800d3a:	eb 22                	jmp    800d5e <getuint+0x38>
	else if (lflag)
  800d3c:	85 d2                	test   %edx,%edx
  800d3e:	74 10                	je     800d50 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800d40:	8b 10                	mov    (%eax),%edx
  800d42:	8d 4a 04             	lea    0x4(%edx),%ecx
  800d45:	89 08                	mov    %ecx,(%eax)
  800d47:	8b 02                	mov    (%edx),%eax
  800d49:	ba 00 00 00 00       	mov    $0x0,%edx
  800d4e:	eb 0e                	jmp    800d5e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800d50:	8b 10                	mov    (%eax),%edx
  800d52:	8d 4a 04             	lea    0x4(%edx),%ecx
  800d55:	89 08                	mov    %ecx,(%eax)
  800d57:	8b 02                	mov    (%edx),%eax
  800d59:	ba 00 00 00 00       	mov    $0x0,%edx
}
  800d5e:	5d                   	pop    %ebp
  800d5f:	c3                   	ret    

00800d60 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800d60:	55                   	push   %ebp
  800d61:	89 e5                	mov    %esp,%ebp
  800d63:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800d66:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  800d6a:	8b 10                	mov    (%eax),%edx
  800d6c:	3b 50 04             	cmp    0x4(%eax),%edx
  800d6f:	73 0a                	jae    800d7b <sprintputch+0x1b>
		*b->buf++ = ch;
  800d71:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800d74:	88 0a                	mov    %cl,(%edx)
  800d76:	83 c2 01             	add    $0x1,%edx
  800d79:	89 10                	mov    %edx,(%eax)
}
  800d7b:	5d                   	pop    %ebp
  800d7c:	c3                   	ret    

00800d7d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  800d7d:	55                   	push   %ebp
  800d7e:	89 e5                	mov    %esp,%ebp
  800d80:	57                   	push   %edi
  800d81:	56                   	push   %esi
  800d82:	53                   	push   %ebx
  800d83:	83 ec 5c             	sub    $0x5c,%esp
  800d86:	8b 7d 08             	mov    0x8(%ebp),%edi
  800d89:	8b 75 0c             	mov    0xc(%ebp),%esi
  800d8c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  800d8f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800d96:	eb 11                	jmp    800da9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800d98:	85 c0                	test   %eax,%eax
  800d9a:	0f 84 f9 03 00 00    	je     801199 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800da0:	89 74 24 04          	mov    %esi,0x4(%esp)
  800da4:	89 04 24             	mov    %eax,(%esp)
  800da7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800da9:	0f b6 03             	movzbl (%ebx),%eax
  800dac:	83 c3 01             	add    $0x1,%ebx
  800daf:	83 f8 25             	cmp    $0x25,%eax
  800db2:	75 e4                	jne    800d98 <vprintfmt+0x1b>
  800db4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800db8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  800dbf:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800dc6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  800dcd:	b9 00 00 00 00       	mov    $0x0,%ecx
  800dd2:	eb 06                	jmp    800dda <vprintfmt+0x5d>
  800dd4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800dd8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  800dda:	0f b6 13             	movzbl (%ebx),%edx
  800ddd:	0f b6 c2             	movzbl %dl,%eax
  800de0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800de3:	8d 43 01             	lea    0x1(%ebx),%eax
  800de6:	83 ea 23             	sub    $0x23,%edx
  800de9:	80 fa 55             	cmp    $0x55,%dl
  800dec:	0f 87 8a 03 00 00    	ja     80117c <vprintfmt+0x3ff>
  800df2:	0f b6 d2             	movzbl %dl,%edx
  800df5:	ff 24 95 60 41 80 00 	jmp    *0x804160(,%edx,4)
  800dfc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800e00:	eb d6                	jmp    800dd8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800e02:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800e05:	83 ea 30             	sub    $0x30,%edx
  800e08:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  800e0b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800e0e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800e11:	83 fb 09             	cmp    $0x9,%ebx
  800e14:	77 54                	ja     800e6a <vprintfmt+0xed>
  800e16:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800e19:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  800e1c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  800e1f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800e22:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800e26:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800e29:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800e2c:	83 fb 09             	cmp    $0x9,%ebx
  800e2f:	76 eb                	jbe    800e1c <vprintfmt+0x9f>
  800e31:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800e34:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800e37:	eb 31                	jmp    800e6a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800e39:	8b 55 14             	mov    0x14(%ebp),%edx
  800e3c:	8d 5a 04             	lea    0x4(%edx),%ebx
  800e3f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800e42:	8b 12                	mov    (%edx),%edx
  800e44:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800e47:	eb 21                	jmp    800e6a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800e49:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800e4d:	ba 00 00 00 00       	mov    $0x0,%edx
  800e52:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800e56:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800e59:	e9 7a ff ff ff       	jmp    800dd8 <vprintfmt+0x5b>
  800e5e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800e65:	e9 6e ff ff ff       	jmp    800dd8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  800e6a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800e6e:	0f 89 64 ff ff ff    	jns    800dd8 <vprintfmt+0x5b>
  800e74:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800e77:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800e7a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  800e7d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800e80:	e9 53 ff ff ff       	jmp    800dd8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800e85:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800e88:	e9 4b ff ff ff       	jmp    800dd8 <vprintfmt+0x5b>
  800e8d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800e90:	8b 45 14             	mov    0x14(%ebp),%eax
  800e93:	8d 50 04             	lea    0x4(%eax),%edx
  800e96:	89 55 14             	mov    %edx,0x14(%ebp)
  800e99:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e9d:	8b 00                	mov    (%eax),%eax
  800e9f:	89 04 24             	mov    %eax,(%esp)
  800ea2:	ff d7                	call   *%edi
  800ea4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800ea7:	e9 fd fe ff ff       	jmp    800da9 <vprintfmt+0x2c>
  800eac:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  800eaf:	8b 45 14             	mov    0x14(%ebp),%eax
  800eb2:	8d 50 04             	lea    0x4(%eax),%edx
  800eb5:	89 55 14             	mov    %edx,0x14(%ebp)
  800eb8:	8b 00                	mov    (%eax),%eax
  800eba:	89 c2                	mov    %eax,%edx
  800ebc:	c1 fa 1f             	sar    $0x1f,%edx
  800ebf:	31 d0                	xor    %edx,%eax
  800ec1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800ec3:	83 f8 12             	cmp    $0x12,%eax
  800ec6:	7f 0b                	jg     800ed3 <vprintfmt+0x156>
  800ec8:	8b 14 85 c0 42 80 00 	mov    0x8042c0(,%eax,4),%edx
  800ecf:	85 d2                	test   %edx,%edx
  800ed1:	75 20                	jne    800ef3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800ed3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800ed7:	c7 44 24 08 3e 40 80 	movl   $0x80403e,0x8(%esp)
  800ede:	00 
  800edf:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ee3:	89 3c 24             	mov    %edi,(%esp)
  800ee6:	e8 36 03 00 00       	call   801221 <printfmt>
  800eeb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800eee:	e9 b6 fe ff ff       	jmp    800da9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800ef3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800ef7:	c7 44 24 08 b3 3f 80 	movl   $0x803fb3,0x8(%esp)
  800efe:	00 
  800eff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f03:	89 3c 24             	mov    %edi,(%esp)
  800f06:	e8 16 03 00 00       	call   801221 <printfmt>
  800f0b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  800f0e:	e9 96 fe ff ff       	jmp    800da9 <vprintfmt+0x2c>
  800f13:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800f16:	89 c3                	mov    %eax,%ebx
  800f18:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800f1b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800f1e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800f21:	8b 45 14             	mov    0x14(%ebp),%eax
  800f24:	8d 50 04             	lea    0x4(%eax),%edx
  800f27:	89 55 14             	mov    %edx,0x14(%ebp)
  800f2a:	8b 00                	mov    (%eax),%eax
  800f2c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800f2f:	85 c0                	test   %eax,%eax
  800f31:	b8 47 40 80 00       	mov    $0x804047,%eax
  800f36:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  800f3a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  800f3d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800f41:	7e 06                	jle    800f49 <vprintfmt+0x1cc>
  800f43:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800f47:	75 13                	jne    800f5c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800f49:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800f4c:	0f be 02             	movsbl (%edx),%eax
  800f4f:	85 c0                	test   %eax,%eax
  800f51:	0f 85 9b 00 00 00    	jne    800ff2 <vprintfmt+0x275>
  800f57:	e9 88 00 00 00       	jmp    800fe4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  800f5c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800f60:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800f63:	89 0c 24             	mov    %ecx,(%esp)
  800f66:	e8 f0 03 00 00       	call   80135b <strnlen>
  800f6b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  800f6e:	29 c2                	sub    %eax,%edx
  800f70:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800f73:	85 d2                	test   %edx,%edx
  800f75:	7e d2                	jle    800f49 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800f77:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  800f7b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  800f7e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800f81:	89 d3                	mov    %edx,%ebx
  800f83:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f87:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  800f8a:	89 04 24             	mov    %eax,(%esp)
  800f8d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  800f8f:	83 eb 01             	sub    $0x1,%ebx
  800f92:	85 db                	test   %ebx,%ebx
  800f94:	7f ed                	jg     800f83 <vprintfmt+0x206>
  800f96:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800f99:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800fa0:	eb a7                	jmp    800f49 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800fa2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800fa6:	74 1a                	je     800fc2 <vprintfmt+0x245>
  800fa8:	8d 50 e0             	lea    -0x20(%eax),%edx
  800fab:	83 fa 5e             	cmp    $0x5e,%edx
  800fae:	76 12                	jbe    800fc2 <vprintfmt+0x245>
					putch('?', putdat);
  800fb0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800fb4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  800fbb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800fbe:	66 90                	xchg   %ax,%ax
  800fc0:	eb 0a                	jmp    800fcc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800fc2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800fc6:	89 04 24             	mov    %eax,(%esp)
  800fc9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800fcc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800fd0:	0f be 03             	movsbl (%ebx),%eax
  800fd3:	85 c0                	test   %eax,%eax
  800fd5:	74 05                	je     800fdc <vprintfmt+0x25f>
  800fd7:	83 c3 01             	add    $0x1,%ebx
  800fda:	eb 29                	jmp    801005 <vprintfmt+0x288>
  800fdc:	89 fe                	mov    %edi,%esi
  800fde:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800fe1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800fe4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800fe8:	7f 2e                	jg     801018 <vprintfmt+0x29b>
  800fea:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  800fed:	e9 b7 fd ff ff       	jmp    800da9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800ff2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800ff5:	83 c2 01             	add    $0x1,%edx
  800ff8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  800ffb:	89 f7                	mov    %esi,%edi
  800ffd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  801000:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  801003:	89 d3                	mov    %edx,%ebx
  801005:	85 f6                	test   %esi,%esi
  801007:	78 99                	js     800fa2 <vprintfmt+0x225>
  801009:	83 ee 01             	sub    $0x1,%esi
  80100c:	79 94                	jns    800fa2 <vprintfmt+0x225>
  80100e:	89 fe                	mov    %edi,%esi
  801010:	8b 7d e0             	mov    -0x20(%ebp),%edi
  801013:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  801016:	eb cc                	jmp    800fe4 <vprintfmt+0x267>
  801018:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80101b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80101e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801022:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  801029:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80102b:	83 eb 01             	sub    $0x1,%ebx
  80102e:	85 db                	test   %ebx,%ebx
  801030:	7f ec                	jg     80101e <vprintfmt+0x2a1>
  801032:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  801035:	e9 6f fd ff ff       	jmp    800da9 <vprintfmt+0x2c>
  80103a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80103d:	83 f9 01             	cmp    $0x1,%ecx
  801040:	7e 16                	jle    801058 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  801042:	8b 45 14             	mov    0x14(%ebp),%eax
  801045:	8d 50 08             	lea    0x8(%eax),%edx
  801048:	89 55 14             	mov    %edx,0x14(%ebp)
  80104b:	8b 10                	mov    (%eax),%edx
  80104d:	8b 48 04             	mov    0x4(%eax),%ecx
  801050:	89 55 d8             	mov    %edx,-0x28(%ebp)
  801053:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  801056:	eb 32                	jmp    80108a <vprintfmt+0x30d>
	else if (lflag)
  801058:	85 c9                	test   %ecx,%ecx
  80105a:	74 18                	je     801074 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80105c:	8b 45 14             	mov    0x14(%ebp),%eax
  80105f:	8d 50 04             	lea    0x4(%eax),%edx
  801062:	89 55 14             	mov    %edx,0x14(%ebp)
  801065:	8b 00                	mov    (%eax),%eax
  801067:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80106a:	89 c1                	mov    %eax,%ecx
  80106c:	c1 f9 1f             	sar    $0x1f,%ecx
  80106f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  801072:	eb 16                	jmp    80108a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  801074:	8b 45 14             	mov    0x14(%ebp),%eax
  801077:	8d 50 04             	lea    0x4(%eax),%edx
  80107a:	89 55 14             	mov    %edx,0x14(%ebp)
  80107d:	8b 00                	mov    (%eax),%eax
  80107f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  801082:	89 c2                	mov    %eax,%edx
  801084:	c1 fa 1f             	sar    $0x1f,%edx
  801087:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80108a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80108d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  801090:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  801095:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  801099:	0f 89 9b 00 00 00    	jns    80113a <vprintfmt+0x3bd>
				putch('-', putdat);
  80109f:	89 74 24 04          	mov    %esi,0x4(%esp)
  8010a3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8010aa:	ff d7                	call   *%edi
				num = -(long long) num;
  8010ac:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8010af:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8010b2:	f7 d9                	neg    %ecx
  8010b4:	83 d3 00             	adc    $0x0,%ebx
  8010b7:	f7 db                	neg    %ebx
  8010b9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8010be:	eb 7a                	jmp    80113a <vprintfmt+0x3bd>
  8010c0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8010c3:	89 ca                	mov    %ecx,%edx
  8010c5:	8d 45 14             	lea    0x14(%ebp),%eax
  8010c8:	e8 59 fc ff ff       	call   800d26 <getuint>
  8010cd:	89 c1                	mov    %eax,%ecx
  8010cf:	89 d3                	mov    %edx,%ebx
  8010d1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  8010d6:	eb 62                	jmp    80113a <vprintfmt+0x3bd>
  8010d8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  8010db:	89 ca                	mov    %ecx,%edx
  8010dd:	8d 45 14             	lea    0x14(%ebp),%eax
  8010e0:	e8 41 fc ff ff       	call   800d26 <getuint>
  8010e5:	89 c1                	mov    %eax,%ecx
  8010e7:	89 d3                	mov    %edx,%ebx
  8010e9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8010ee:	eb 4a                	jmp    80113a <vprintfmt+0x3bd>
  8010f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8010f3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8010f7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8010fe:	ff d7                	call   *%edi
			putch('x', putdat);
  801100:	89 74 24 04          	mov    %esi,0x4(%esp)
  801104:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80110b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80110d:	8b 45 14             	mov    0x14(%ebp),%eax
  801110:	8d 50 04             	lea    0x4(%eax),%edx
  801113:	89 55 14             	mov    %edx,0x14(%ebp)
  801116:	8b 08                	mov    (%eax),%ecx
  801118:	bb 00 00 00 00       	mov    $0x0,%ebx
  80111d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  801122:	eb 16                	jmp    80113a <vprintfmt+0x3bd>
  801124:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  801127:	89 ca                	mov    %ecx,%edx
  801129:	8d 45 14             	lea    0x14(%ebp),%eax
  80112c:	e8 f5 fb ff ff       	call   800d26 <getuint>
  801131:	89 c1                	mov    %eax,%ecx
  801133:	89 d3                	mov    %edx,%ebx
  801135:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80113a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80113e:	89 54 24 10          	mov    %edx,0x10(%esp)
  801142:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801145:	89 54 24 0c          	mov    %edx,0xc(%esp)
  801149:	89 44 24 08          	mov    %eax,0x8(%esp)
  80114d:	89 0c 24             	mov    %ecx,(%esp)
  801150:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801154:	89 f2                	mov    %esi,%edx
  801156:	89 f8                	mov    %edi,%eax
  801158:	e8 d3 fa ff ff       	call   800c30 <printnum>
  80115d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  801160:	e9 44 fc ff ff       	jmp    800da9 <vprintfmt+0x2c>
  801165:	89 45 cc             	mov    %eax,-0x34(%ebp)
  801168:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80116b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80116f:	89 14 24             	mov    %edx,(%esp)
  801172:	ff d7                	call   *%edi
  801174:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  801177:	e9 2d fc ff ff       	jmp    800da9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  80117c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801180:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  801187:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  801189:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80118c:	80 38 25             	cmpb   $0x25,(%eax)
  80118f:	0f 84 14 fc ff ff    	je     800da9 <vprintfmt+0x2c>
  801195:	89 c3                	mov    %eax,%ebx
  801197:	eb f0                	jmp    801189 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  801199:	83 c4 5c             	add    $0x5c,%esp
  80119c:	5b                   	pop    %ebx
  80119d:	5e                   	pop    %esi
  80119e:	5f                   	pop    %edi
  80119f:	5d                   	pop    %ebp
  8011a0:	c3                   	ret    

008011a1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8011a1:	55                   	push   %ebp
  8011a2:	89 e5                	mov    %esp,%ebp
  8011a4:	83 ec 28             	sub    $0x28,%esp
  8011a7:	8b 45 08             	mov    0x8(%ebp),%eax
  8011aa:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  8011ad:	85 c0                	test   %eax,%eax
  8011af:	74 04                	je     8011b5 <vsnprintf+0x14>
  8011b1:	85 d2                	test   %edx,%edx
  8011b3:	7f 07                	jg     8011bc <vsnprintf+0x1b>
  8011b5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8011ba:	eb 3b                	jmp    8011f7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  8011bc:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8011bf:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8011c3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8011c6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8011cd:	8b 45 14             	mov    0x14(%ebp),%eax
  8011d0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8011d4:	8b 45 10             	mov    0x10(%ebp),%eax
  8011d7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8011db:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8011de:	89 44 24 04          	mov    %eax,0x4(%esp)
  8011e2:	c7 04 24 60 0d 80 00 	movl   $0x800d60,(%esp)
  8011e9:	e8 8f fb ff ff       	call   800d7d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8011ee:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8011f1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8011f4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  8011f7:	c9                   	leave  
  8011f8:	c3                   	ret    

008011f9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8011f9:	55                   	push   %ebp
  8011fa:	89 e5                	mov    %esp,%ebp
  8011fc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  8011ff:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  801202:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801206:	8b 45 10             	mov    0x10(%ebp),%eax
  801209:	89 44 24 08          	mov    %eax,0x8(%esp)
  80120d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801210:	89 44 24 04          	mov    %eax,0x4(%esp)
  801214:	8b 45 08             	mov    0x8(%ebp),%eax
  801217:	89 04 24             	mov    %eax,(%esp)
  80121a:	e8 82 ff ff ff       	call   8011a1 <vsnprintf>
	va_end(ap);

	return rc;
}
  80121f:	c9                   	leave  
  801220:	c3                   	ret    

00801221 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  801221:	55                   	push   %ebp
  801222:	89 e5                	mov    %esp,%ebp
  801224:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  801227:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80122a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80122e:	8b 45 10             	mov    0x10(%ebp),%eax
  801231:	89 44 24 08          	mov    %eax,0x8(%esp)
  801235:	8b 45 0c             	mov    0xc(%ebp),%eax
  801238:	89 44 24 04          	mov    %eax,0x4(%esp)
  80123c:	8b 45 08             	mov    0x8(%ebp),%eax
  80123f:	89 04 24             	mov    %eax,(%esp)
  801242:	e8 36 fb ff ff       	call   800d7d <vprintfmt>
	va_end(ap);
}
  801247:	c9                   	leave  
  801248:	c3                   	ret    
  801249:	00 00                	add    %al,(%eax)
  80124b:	00 00                	add    %al,(%eax)
  80124d:	00 00                	add    %al,(%eax)
	...

00801250 <readline>:
#define BUFLEN 1024
static char buf[BUFLEN];

char *
readline(const char *prompt)
{
  801250:	55                   	push   %ebp
  801251:	89 e5                	mov    %esp,%ebp
  801253:	57                   	push   %edi
  801254:	56                   	push   %esi
  801255:	53                   	push   %ebx
  801256:	83 ec 1c             	sub    $0x1c,%esp
  801259:	8b 45 08             	mov    0x8(%ebp),%eax

#if JOS_KERNEL
	if (prompt != NULL)
		cprintf("%s", prompt);
#else
	if (prompt != NULL)
  80125c:	85 c0                	test   %eax,%eax
  80125e:	74 18                	je     801278 <readline+0x28>
		fprintf(1, "%s", prompt);
  801260:	89 44 24 08          	mov    %eax,0x8(%esp)
  801264:	c7 44 24 04 b3 3f 80 	movl   $0x803fb3,0x4(%esp)
  80126b:	00 
  80126c:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  801273:	e8 91 17 00 00       	call   802a09 <fprintf>
#endif

	i = 0;
	echoing = iscons(0);
  801278:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80127f:	e8 a9 f7 ff ff       	call   800a2d <iscons>
  801284:	89 c7                	mov    %eax,%edi
  801286:	be 00 00 00 00       	mov    $0x0,%esi
	while (1) {
		c = getchar();
  80128b:	e8 cc f7 ff ff       	call   800a5c <getchar>
  801290:	89 c3                	mov    %eax,%ebx
		if (c < 0) {
  801292:	85 c0                	test   %eax,%eax
  801294:	79 25                	jns    8012bb <readline+0x6b>
			if (c != -E_EOF)
  801296:	b8 00 00 00 00       	mov    $0x0,%eax
  80129b:	83 fb f8             	cmp    $0xfffffff8,%ebx
  80129e:	0f 84 8f 00 00 00    	je     801333 <readline+0xe3>
				cprintf("read error: %e\n", c);
  8012a4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8012a8:	c7 04 24 2b 43 80 00 	movl   $0x80432b,(%esp)
  8012af:	e8 11 f9 ff ff       	call   800bc5 <cprintf>
  8012b4:	b8 00 00 00 00       	mov    $0x0,%eax
  8012b9:	eb 78                	jmp    801333 <readline+0xe3>
			return NULL;
		} else if ((c == '\b' || c == '\x7f') && i > 0) {
  8012bb:	83 f8 08             	cmp    $0x8,%eax
  8012be:	74 05                	je     8012c5 <readline+0x75>
  8012c0:	83 f8 7f             	cmp    $0x7f,%eax
  8012c3:	75 1e                	jne    8012e3 <readline+0x93>
  8012c5:	85 f6                	test   %esi,%esi
  8012c7:	7e 1a                	jle    8012e3 <readline+0x93>
			if (echoing)
  8012c9:	85 ff                	test   %edi,%edi
  8012cb:	90                   	nop
  8012cc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8012d0:	74 0c                	je     8012de <readline+0x8e>
				cputchar('\b');
  8012d2:	c7 04 24 08 00 00 00 	movl   $0x8,(%esp)
  8012d9:	e8 96 f6 ff ff       	call   800974 <cputchar>
			i--;
  8012de:	83 ee 01             	sub    $0x1,%esi
		c = getchar();
		if (c < 0) {
			if (c != -E_EOF)
				cprintf("read error: %e\n", c);
			return NULL;
		} else if ((c == '\b' || c == '\x7f') && i > 0) {
  8012e1:	eb a8                	jmp    80128b <readline+0x3b>
			if (echoing)
				cputchar('\b');
			i--;
		} else if (c >= ' ' && i < BUFLEN-1) {
  8012e3:	83 fb 1f             	cmp    $0x1f,%ebx
  8012e6:	7e 21                	jle    801309 <readline+0xb9>
  8012e8:	81 fe fe 03 00 00    	cmp    $0x3fe,%esi
  8012ee:	66 90                	xchg   %ax,%ax
  8012f0:	7f 17                	jg     801309 <readline+0xb9>
			if (echoing)
  8012f2:	85 ff                	test   %edi,%edi
  8012f4:	74 08                	je     8012fe <readline+0xae>
				cputchar(c);
  8012f6:	89 1c 24             	mov    %ebx,(%esp)
  8012f9:	e8 76 f6 ff ff       	call   800974 <cputchar>
			buf[i++] = c;
  8012fe:	88 9e a0 80 80 00    	mov    %bl,0x8080a0(%esi)
  801304:	83 c6 01             	add    $0x1,%esi
  801307:	eb 82                	jmp    80128b <readline+0x3b>
		} else if (c == '\n' || c == '\r') {
  801309:	83 fb 0a             	cmp    $0xa,%ebx
  80130c:	74 09                	je     801317 <readline+0xc7>
  80130e:	83 fb 0d             	cmp    $0xd,%ebx
  801311:	0f 85 74 ff ff ff    	jne    80128b <readline+0x3b>
			if (echoing)
  801317:	85 ff                	test   %edi,%edi
  801319:	74 0c                	je     801327 <readline+0xd7>
				cputchar('\n');
  80131b:	c7 04 24 0a 00 00 00 	movl   $0xa,(%esp)
  801322:	e8 4d f6 ff ff       	call   800974 <cputchar>
			buf[i] = 0;
  801327:	c6 86 a0 80 80 00 00 	movb   $0x0,0x8080a0(%esi)
  80132e:	b8 a0 80 80 00       	mov    $0x8080a0,%eax
			return buf;
		}
	}
}
  801333:	83 c4 1c             	add    $0x1c,%esp
  801336:	5b                   	pop    %ebx
  801337:	5e                   	pop    %esi
  801338:	5f                   	pop    %edi
  801339:	5d                   	pop    %ebp
  80133a:	c3                   	ret    
  80133b:	00 00                	add    %al,(%eax)
  80133d:	00 00                	add    %al,(%eax)
	...

00801340 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  801340:	55                   	push   %ebp
  801341:	89 e5                	mov    %esp,%ebp
  801343:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  801346:	b8 00 00 00 00       	mov    $0x0,%eax
  80134b:	80 3a 00             	cmpb   $0x0,(%edx)
  80134e:	74 09                	je     801359 <strlen+0x19>
		n++;
  801350:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  801353:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  801357:	75 f7                	jne    801350 <strlen+0x10>
		n++;
	return n;
}
  801359:	5d                   	pop    %ebp
  80135a:	c3                   	ret    

0080135b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80135b:	55                   	push   %ebp
  80135c:	89 e5                	mov    %esp,%ebp
  80135e:	53                   	push   %ebx
  80135f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801362:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  801365:	85 c9                	test   %ecx,%ecx
  801367:	74 19                	je     801382 <strnlen+0x27>
  801369:	80 3b 00             	cmpb   $0x0,(%ebx)
  80136c:	74 14                	je     801382 <strnlen+0x27>
  80136e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  801373:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  801376:	39 c8                	cmp    %ecx,%eax
  801378:	74 0d                	je     801387 <strnlen+0x2c>
  80137a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  80137e:	75 f3                	jne    801373 <strnlen+0x18>
  801380:	eb 05                	jmp    801387 <strnlen+0x2c>
  801382:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  801387:	5b                   	pop    %ebx
  801388:	5d                   	pop    %ebp
  801389:	c3                   	ret    

0080138a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80138a:	55                   	push   %ebp
  80138b:	89 e5                	mov    %esp,%ebp
  80138d:	53                   	push   %ebx
  80138e:	8b 45 08             	mov    0x8(%ebp),%eax
  801391:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  801394:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  801399:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  80139d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  8013a0:	83 c2 01             	add    $0x1,%edx
  8013a3:	84 c9                	test   %cl,%cl
  8013a5:	75 f2                	jne    801399 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  8013a7:	5b                   	pop    %ebx
  8013a8:	5d                   	pop    %ebp
  8013a9:	c3                   	ret    

008013aa <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8013aa:	55                   	push   %ebp
  8013ab:	89 e5                	mov    %esp,%ebp
  8013ad:	56                   	push   %esi
  8013ae:	53                   	push   %ebx
  8013af:	8b 45 08             	mov    0x8(%ebp),%eax
  8013b2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8013b5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8013b8:	85 f6                	test   %esi,%esi
  8013ba:	74 18                	je     8013d4 <strncpy+0x2a>
  8013bc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  8013c1:	0f b6 1a             	movzbl (%edx),%ebx
  8013c4:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  8013c7:	80 3a 01             	cmpb   $0x1,(%edx)
  8013ca:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8013cd:	83 c1 01             	add    $0x1,%ecx
  8013d0:	39 ce                	cmp    %ecx,%esi
  8013d2:	77 ed                	ja     8013c1 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  8013d4:	5b                   	pop    %ebx
  8013d5:	5e                   	pop    %esi
  8013d6:	5d                   	pop    %ebp
  8013d7:	c3                   	ret    

008013d8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8013d8:	55                   	push   %ebp
  8013d9:	89 e5                	mov    %esp,%ebp
  8013db:	56                   	push   %esi
  8013dc:	53                   	push   %ebx
  8013dd:	8b 75 08             	mov    0x8(%ebp),%esi
  8013e0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8013e3:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8013e6:	89 f0                	mov    %esi,%eax
  8013e8:	85 c9                	test   %ecx,%ecx
  8013ea:	74 27                	je     801413 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  8013ec:	83 e9 01             	sub    $0x1,%ecx
  8013ef:	74 1d                	je     80140e <strlcpy+0x36>
  8013f1:	0f b6 1a             	movzbl (%edx),%ebx
  8013f4:	84 db                	test   %bl,%bl
  8013f6:	74 16                	je     80140e <strlcpy+0x36>
			*dst++ = *src++;
  8013f8:	88 18                	mov    %bl,(%eax)
  8013fa:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  8013fd:	83 e9 01             	sub    $0x1,%ecx
  801400:	74 0e                	je     801410 <strlcpy+0x38>
			*dst++ = *src++;
  801402:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  801405:	0f b6 1a             	movzbl (%edx),%ebx
  801408:	84 db                	test   %bl,%bl
  80140a:	75 ec                	jne    8013f8 <strlcpy+0x20>
  80140c:	eb 02                	jmp    801410 <strlcpy+0x38>
  80140e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  801410:	c6 00 00             	movb   $0x0,(%eax)
  801413:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  801415:	5b                   	pop    %ebx
  801416:	5e                   	pop    %esi
  801417:	5d                   	pop    %ebp
  801418:	c3                   	ret    

00801419 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  801419:	55                   	push   %ebp
  80141a:	89 e5                	mov    %esp,%ebp
  80141c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80141f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  801422:	0f b6 01             	movzbl (%ecx),%eax
  801425:	84 c0                	test   %al,%al
  801427:	74 15                	je     80143e <strcmp+0x25>
  801429:	3a 02                	cmp    (%edx),%al
  80142b:	75 11                	jne    80143e <strcmp+0x25>
		p++, q++;
  80142d:	83 c1 01             	add    $0x1,%ecx
  801430:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  801433:	0f b6 01             	movzbl (%ecx),%eax
  801436:	84 c0                	test   %al,%al
  801438:	74 04                	je     80143e <strcmp+0x25>
  80143a:	3a 02                	cmp    (%edx),%al
  80143c:	74 ef                	je     80142d <strcmp+0x14>
  80143e:	0f b6 c0             	movzbl %al,%eax
  801441:	0f b6 12             	movzbl (%edx),%edx
  801444:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  801446:	5d                   	pop    %ebp
  801447:	c3                   	ret    

00801448 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  801448:	55                   	push   %ebp
  801449:	89 e5                	mov    %esp,%ebp
  80144b:	53                   	push   %ebx
  80144c:	8b 55 08             	mov    0x8(%ebp),%edx
  80144f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801452:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  801455:	85 c0                	test   %eax,%eax
  801457:	74 23                	je     80147c <strncmp+0x34>
  801459:	0f b6 1a             	movzbl (%edx),%ebx
  80145c:	84 db                	test   %bl,%bl
  80145e:	74 24                	je     801484 <strncmp+0x3c>
  801460:	3a 19                	cmp    (%ecx),%bl
  801462:	75 20                	jne    801484 <strncmp+0x3c>
  801464:	83 e8 01             	sub    $0x1,%eax
  801467:	74 13                	je     80147c <strncmp+0x34>
		n--, p++, q++;
  801469:	83 c2 01             	add    $0x1,%edx
  80146c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  80146f:	0f b6 1a             	movzbl (%edx),%ebx
  801472:	84 db                	test   %bl,%bl
  801474:	74 0e                	je     801484 <strncmp+0x3c>
  801476:	3a 19                	cmp    (%ecx),%bl
  801478:	74 ea                	je     801464 <strncmp+0x1c>
  80147a:	eb 08                	jmp    801484 <strncmp+0x3c>
  80147c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  801481:	5b                   	pop    %ebx
  801482:	5d                   	pop    %ebp
  801483:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  801484:	0f b6 02             	movzbl (%edx),%eax
  801487:	0f b6 11             	movzbl (%ecx),%edx
  80148a:	29 d0                	sub    %edx,%eax
  80148c:	eb f3                	jmp    801481 <strncmp+0x39>

0080148e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  80148e:	55                   	push   %ebp
  80148f:	89 e5                	mov    %esp,%ebp
  801491:	8b 45 08             	mov    0x8(%ebp),%eax
  801494:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  801498:	0f b6 10             	movzbl (%eax),%edx
  80149b:	84 d2                	test   %dl,%dl
  80149d:	74 15                	je     8014b4 <strchr+0x26>
		if (*s == c)
  80149f:	38 ca                	cmp    %cl,%dl
  8014a1:	75 07                	jne    8014aa <strchr+0x1c>
  8014a3:	eb 14                	jmp    8014b9 <strchr+0x2b>
  8014a5:	38 ca                	cmp    %cl,%dl
  8014a7:	90                   	nop
  8014a8:	74 0f                	je     8014b9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  8014aa:	83 c0 01             	add    $0x1,%eax
  8014ad:	0f b6 10             	movzbl (%eax),%edx
  8014b0:	84 d2                	test   %dl,%dl
  8014b2:	75 f1                	jne    8014a5 <strchr+0x17>
  8014b4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  8014b9:	5d                   	pop    %ebp
  8014ba:	c3                   	ret    

008014bb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  8014bb:	55                   	push   %ebp
  8014bc:	89 e5                	mov    %esp,%ebp
  8014be:	8b 45 08             	mov    0x8(%ebp),%eax
  8014c1:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  8014c5:	0f b6 10             	movzbl (%eax),%edx
  8014c8:	84 d2                	test   %dl,%dl
  8014ca:	74 18                	je     8014e4 <strfind+0x29>
		if (*s == c)
  8014cc:	38 ca                	cmp    %cl,%dl
  8014ce:	75 0a                	jne    8014da <strfind+0x1f>
  8014d0:	eb 12                	jmp    8014e4 <strfind+0x29>
  8014d2:	38 ca                	cmp    %cl,%dl
  8014d4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8014d8:	74 0a                	je     8014e4 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  8014da:	83 c0 01             	add    $0x1,%eax
  8014dd:	0f b6 10             	movzbl (%eax),%edx
  8014e0:	84 d2                	test   %dl,%dl
  8014e2:	75 ee                	jne    8014d2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  8014e4:	5d                   	pop    %ebp
  8014e5:	c3                   	ret    

008014e6 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  8014e6:	55                   	push   %ebp
  8014e7:	89 e5                	mov    %esp,%ebp
  8014e9:	83 ec 0c             	sub    $0xc,%esp
  8014ec:	89 1c 24             	mov    %ebx,(%esp)
  8014ef:	89 74 24 04          	mov    %esi,0x4(%esp)
  8014f3:	89 7c 24 08          	mov    %edi,0x8(%esp)
  8014f7:	8b 7d 08             	mov    0x8(%ebp),%edi
  8014fa:	8b 45 0c             	mov    0xc(%ebp),%eax
  8014fd:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  801500:	85 c9                	test   %ecx,%ecx
  801502:	74 30                	je     801534 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  801504:	f7 c7 03 00 00 00    	test   $0x3,%edi
  80150a:	75 25                	jne    801531 <memset+0x4b>
  80150c:	f6 c1 03             	test   $0x3,%cl
  80150f:	75 20                	jne    801531 <memset+0x4b>
		c &= 0xFF;
  801511:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  801514:	89 d3                	mov    %edx,%ebx
  801516:	c1 e3 08             	shl    $0x8,%ebx
  801519:	89 d6                	mov    %edx,%esi
  80151b:	c1 e6 18             	shl    $0x18,%esi
  80151e:	89 d0                	mov    %edx,%eax
  801520:	c1 e0 10             	shl    $0x10,%eax
  801523:	09 f0                	or     %esi,%eax
  801525:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  801527:	09 d8                	or     %ebx,%eax
  801529:	c1 e9 02             	shr    $0x2,%ecx
  80152c:	fc                   	cld    
  80152d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  80152f:	eb 03                	jmp    801534 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  801531:	fc                   	cld    
  801532:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  801534:	89 f8                	mov    %edi,%eax
  801536:	8b 1c 24             	mov    (%esp),%ebx
  801539:	8b 74 24 04          	mov    0x4(%esp),%esi
  80153d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801541:	89 ec                	mov    %ebp,%esp
  801543:	5d                   	pop    %ebp
  801544:	c3                   	ret    

00801545 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  801545:	55                   	push   %ebp
  801546:	89 e5                	mov    %esp,%ebp
  801548:	83 ec 08             	sub    $0x8,%esp
  80154b:	89 34 24             	mov    %esi,(%esp)
  80154e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  801552:	8b 45 08             	mov    0x8(%ebp),%eax
  801555:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  801558:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  80155b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  80155d:	39 c6                	cmp    %eax,%esi
  80155f:	73 35                	jae    801596 <memmove+0x51>
  801561:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  801564:	39 d0                	cmp    %edx,%eax
  801566:	73 2e                	jae    801596 <memmove+0x51>
		s += n;
		d += n;
  801568:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  80156a:	f6 c2 03             	test   $0x3,%dl
  80156d:	75 1b                	jne    80158a <memmove+0x45>
  80156f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  801575:	75 13                	jne    80158a <memmove+0x45>
  801577:	f6 c1 03             	test   $0x3,%cl
  80157a:	75 0e                	jne    80158a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  80157c:	83 ef 04             	sub    $0x4,%edi
  80157f:	8d 72 fc             	lea    -0x4(%edx),%esi
  801582:	c1 e9 02             	shr    $0x2,%ecx
  801585:	fd                   	std    
  801586:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  801588:	eb 09                	jmp    801593 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  80158a:	83 ef 01             	sub    $0x1,%edi
  80158d:	8d 72 ff             	lea    -0x1(%edx),%esi
  801590:	fd                   	std    
  801591:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  801593:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  801594:	eb 20                	jmp    8015b6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  801596:	f7 c6 03 00 00 00    	test   $0x3,%esi
  80159c:	75 15                	jne    8015b3 <memmove+0x6e>
  80159e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  8015a4:	75 0d                	jne    8015b3 <memmove+0x6e>
  8015a6:	f6 c1 03             	test   $0x3,%cl
  8015a9:	75 08                	jne    8015b3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  8015ab:	c1 e9 02             	shr    $0x2,%ecx
  8015ae:	fc                   	cld    
  8015af:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  8015b1:	eb 03                	jmp    8015b6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  8015b3:	fc                   	cld    
  8015b4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  8015b6:	8b 34 24             	mov    (%esp),%esi
  8015b9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  8015bd:	89 ec                	mov    %ebp,%esp
  8015bf:	5d                   	pop    %ebp
  8015c0:	c3                   	ret    

008015c1 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  8015c1:	55                   	push   %ebp
  8015c2:	89 e5                	mov    %esp,%ebp
  8015c4:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  8015c7:	8b 45 10             	mov    0x10(%ebp),%eax
  8015ca:	89 44 24 08          	mov    %eax,0x8(%esp)
  8015ce:	8b 45 0c             	mov    0xc(%ebp),%eax
  8015d1:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015d5:	8b 45 08             	mov    0x8(%ebp),%eax
  8015d8:	89 04 24             	mov    %eax,(%esp)
  8015db:	e8 65 ff ff ff       	call   801545 <memmove>
}
  8015e0:	c9                   	leave  
  8015e1:	c3                   	ret    

008015e2 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  8015e2:	55                   	push   %ebp
  8015e3:	89 e5                	mov    %esp,%ebp
  8015e5:	57                   	push   %edi
  8015e6:	56                   	push   %esi
  8015e7:	53                   	push   %ebx
  8015e8:	8b 75 08             	mov    0x8(%ebp),%esi
  8015eb:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8015ee:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  8015f1:	85 c9                	test   %ecx,%ecx
  8015f3:	74 36                	je     80162b <memcmp+0x49>
		if (*s1 != *s2)
  8015f5:	0f b6 06             	movzbl (%esi),%eax
  8015f8:	0f b6 1f             	movzbl (%edi),%ebx
  8015fb:	38 d8                	cmp    %bl,%al
  8015fd:	74 20                	je     80161f <memcmp+0x3d>
  8015ff:	eb 14                	jmp    801615 <memcmp+0x33>
  801601:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  801606:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  80160b:	83 c2 01             	add    $0x1,%edx
  80160e:	83 e9 01             	sub    $0x1,%ecx
  801611:	38 d8                	cmp    %bl,%al
  801613:	74 12                	je     801627 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  801615:	0f b6 c0             	movzbl %al,%eax
  801618:	0f b6 db             	movzbl %bl,%ebx
  80161b:	29 d8                	sub    %ebx,%eax
  80161d:	eb 11                	jmp    801630 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  80161f:	83 e9 01             	sub    $0x1,%ecx
  801622:	ba 00 00 00 00       	mov    $0x0,%edx
  801627:	85 c9                	test   %ecx,%ecx
  801629:	75 d6                	jne    801601 <memcmp+0x1f>
  80162b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  801630:	5b                   	pop    %ebx
  801631:	5e                   	pop    %esi
  801632:	5f                   	pop    %edi
  801633:	5d                   	pop    %ebp
  801634:	c3                   	ret    

00801635 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  801635:	55                   	push   %ebp
  801636:	89 e5                	mov    %esp,%ebp
  801638:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  80163b:	89 c2                	mov    %eax,%edx
  80163d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  801640:	39 d0                	cmp    %edx,%eax
  801642:	73 15                	jae    801659 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  801644:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  801648:	38 08                	cmp    %cl,(%eax)
  80164a:	75 06                	jne    801652 <memfind+0x1d>
  80164c:	eb 0b                	jmp    801659 <memfind+0x24>
  80164e:	38 08                	cmp    %cl,(%eax)
  801650:	74 07                	je     801659 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  801652:	83 c0 01             	add    $0x1,%eax
  801655:	39 c2                	cmp    %eax,%edx
  801657:	77 f5                	ja     80164e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  801659:	5d                   	pop    %ebp
  80165a:	c3                   	ret    

0080165b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  80165b:	55                   	push   %ebp
  80165c:	89 e5                	mov    %esp,%ebp
  80165e:	57                   	push   %edi
  80165f:	56                   	push   %esi
  801660:	53                   	push   %ebx
  801661:	83 ec 04             	sub    $0x4,%esp
  801664:	8b 55 08             	mov    0x8(%ebp),%edx
  801667:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  80166a:	0f b6 02             	movzbl (%edx),%eax
  80166d:	3c 20                	cmp    $0x20,%al
  80166f:	74 04                	je     801675 <strtol+0x1a>
  801671:	3c 09                	cmp    $0x9,%al
  801673:	75 0e                	jne    801683 <strtol+0x28>
		s++;
  801675:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  801678:	0f b6 02             	movzbl (%edx),%eax
  80167b:	3c 20                	cmp    $0x20,%al
  80167d:	74 f6                	je     801675 <strtol+0x1a>
  80167f:	3c 09                	cmp    $0x9,%al
  801681:	74 f2                	je     801675 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  801683:	3c 2b                	cmp    $0x2b,%al
  801685:	75 0c                	jne    801693 <strtol+0x38>
		s++;
  801687:	83 c2 01             	add    $0x1,%edx
  80168a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  801691:	eb 15                	jmp    8016a8 <strtol+0x4d>
	else if (*s == '-')
  801693:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  80169a:	3c 2d                	cmp    $0x2d,%al
  80169c:	75 0a                	jne    8016a8 <strtol+0x4d>
		s++, neg = 1;
  80169e:	83 c2 01             	add    $0x1,%edx
  8016a1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  8016a8:	85 db                	test   %ebx,%ebx
  8016aa:	0f 94 c0             	sete   %al
  8016ad:	74 05                	je     8016b4 <strtol+0x59>
  8016af:	83 fb 10             	cmp    $0x10,%ebx
  8016b2:	75 18                	jne    8016cc <strtol+0x71>
  8016b4:	80 3a 30             	cmpb   $0x30,(%edx)
  8016b7:	75 13                	jne    8016cc <strtol+0x71>
  8016b9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  8016bd:	8d 76 00             	lea    0x0(%esi),%esi
  8016c0:	75 0a                	jne    8016cc <strtol+0x71>
		s += 2, base = 16;
  8016c2:	83 c2 02             	add    $0x2,%edx
  8016c5:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  8016ca:	eb 15                	jmp    8016e1 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  8016cc:	84 c0                	test   %al,%al
  8016ce:	66 90                	xchg   %ax,%ax
  8016d0:	74 0f                	je     8016e1 <strtol+0x86>
  8016d2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  8016d7:	80 3a 30             	cmpb   $0x30,(%edx)
  8016da:	75 05                	jne    8016e1 <strtol+0x86>
		s++, base = 8;
  8016dc:	83 c2 01             	add    $0x1,%edx
  8016df:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  8016e1:	b8 00 00 00 00       	mov    $0x0,%eax
  8016e6:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  8016e8:	0f b6 0a             	movzbl (%edx),%ecx
  8016eb:	89 cf                	mov    %ecx,%edi
  8016ed:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  8016f0:	80 fb 09             	cmp    $0x9,%bl
  8016f3:	77 08                	ja     8016fd <strtol+0xa2>
			dig = *s - '0';
  8016f5:	0f be c9             	movsbl %cl,%ecx
  8016f8:	83 e9 30             	sub    $0x30,%ecx
  8016fb:	eb 1e                	jmp    80171b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  8016fd:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  801700:	80 fb 19             	cmp    $0x19,%bl
  801703:	77 08                	ja     80170d <strtol+0xb2>
			dig = *s - 'a' + 10;
  801705:	0f be c9             	movsbl %cl,%ecx
  801708:	83 e9 57             	sub    $0x57,%ecx
  80170b:	eb 0e                	jmp    80171b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  80170d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  801710:	80 fb 19             	cmp    $0x19,%bl
  801713:	77 15                	ja     80172a <strtol+0xcf>
			dig = *s - 'A' + 10;
  801715:	0f be c9             	movsbl %cl,%ecx
  801718:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  80171b:	39 f1                	cmp    %esi,%ecx
  80171d:	7d 0b                	jge    80172a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  80171f:	83 c2 01             	add    $0x1,%edx
  801722:	0f af c6             	imul   %esi,%eax
  801725:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  801728:	eb be                	jmp    8016e8 <strtol+0x8d>
  80172a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  80172c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801730:	74 05                	je     801737 <strtol+0xdc>
		*endptr = (char *) s;
  801732:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  801735:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  801737:	89 ca                	mov    %ecx,%edx
  801739:	f7 da                	neg    %edx
  80173b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  80173f:	0f 45 c2             	cmovne %edx,%eax
}
  801742:	83 c4 04             	add    $0x4,%esp
  801745:	5b                   	pop    %ebx
  801746:	5e                   	pop    %esi
  801747:	5f                   	pop    %edi
  801748:	5d                   	pop    %ebp
  801749:	c3                   	ret    
	...

0080174c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  80174c:	55                   	push   %ebp
  80174d:	89 e5                	mov    %esp,%ebp
  80174f:	83 ec 0c             	sub    $0xc,%esp
  801752:	89 1c 24             	mov    %ebx,(%esp)
  801755:	89 74 24 04          	mov    %esi,0x4(%esp)
  801759:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80175d:	ba 00 00 00 00       	mov    $0x0,%edx
  801762:	b8 01 00 00 00       	mov    $0x1,%eax
  801767:	89 d1                	mov    %edx,%ecx
  801769:	89 d3                	mov    %edx,%ebx
  80176b:	89 d7                	mov    %edx,%edi
  80176d:	89 d6                	mov    %edx,%esi
  80176f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  801771:	8b 1c 24             	mov    (%esp),%ebx
  801774:	8b 74 24 04          	mov    0x4(%esp),%esi
  801778:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80177c:	89 ec                	mov    %ebp,%esp
  80177e:	5d                   	pop    %ebp
  80177f:	c3                   	ret    

00801780 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  801780:	55                   	push   %ebp
  801781:	89 e5                	mov    %esp,%ebp
  801783:	83 ec 0c             	sub    $0xc,%esp
  801786:	89 1c 24             	mov    %ebx,(%esp)
  801789:	89 74 24 04          	mov    %esi,0x4(%esp)
  80178d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801791:	b8 00 00 00 00       	mov    $0x0,%eax
  801796:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801799:	8b 55 08             	mov    0x8(%ebp),%edx
  80179c:	89 c3                	mov    %eax,%ebx
  80179e:	89 c7                	mov    %eax,%edi
  8017a0:	89 c6                	mov    %eax,%esi
  8017a2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  8017a4:	8b 1c 24             	mov    (%esp),%ebx
  8017a7:	8b 74 24 04          	mov    0x4(%esp),%esi
  8017ab:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8017af:	89 ec                	mov    %ebp,%esp
  8017b1:	5d                   	pop    %ebp
  8017b2:	c3                   	ret    

008017b3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  8017b3:	55                   	push   %ebp
  8017b4:	89 e5                	mov    %esp,%ebp
  8017b6:	83 ec 0c             	sub    $0xc,%esp
  8017b9:	89 1c 24             	mov    %ebx,(%esp)
  8017bc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8017c0:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8017c4:	bb 00 00 00 00       	mov    $0x0,%ebx
  8017c9:	b8 10 00 00 00       	mov    $0x10,%eax
  8017ce:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8017d1:	8b 55 08             	mov    0x8(%ebp),%edx
  8017d4:	89 df                	mov    %ebx,%edi
  8017d6:	89 de                	mov    %ebx,%esi
  8017d8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  8017da:	8b 1c 24             	mov    (%esp),%ebx
  8017dd:	8b 74 24 04          	mov    0x4(%esp),%esi
  8017e1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8017e5:	89 ec                	mov    %ebp,%esp
  8017e7:	5d                   	pop    %ebp
  8017e8:	c3                   	ret    

008017e9 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  8017e9:	55                   	push   %ebp
  8017ea:	89 e5                	mov    %esp,%ebp
  8017ec:	83 ec 0c             	sub    $0xc,%esp
  8017ef:	89 1c 24             	mov    %ebx,(%esp)
  8017f2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8017f6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8017fa:	bb 00 00 00 00       	mov    $0x0,%ebx
  8017ff:	b8 0f 00 00 00       	mov    $0xf,%eax
  801804:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801807:	8b 55 08             	mov    0x8(%ebp),%edx
  80180a:	89 df                	mov    %ebx,%edi
  80180c:	89 de                	mov    %ebx,%esi
  80180e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  801810:	8b 1c 24             	mov    (%esp),%ebx
  801813:	8b 74 24 04          	mov    0x4(%esp),%esi
  801817:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80181b:	89 ec                	mov    %ebp,%esp
  80181d:	5d                   	pop    %ebp
  80181e:	c3                   	ret    

0080181f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  80181f:	55                   	push   %ebp
  801820:	89 e5                	mov    %esp,%ebp
  801822:	83 ec 0c             	sub    $0xc,%esp
  801825:	89 1c 24             	mov    %ebx,(%esp)
  801828:	89 74 24 04          	mov    %esi,0x4(%esp)
  80182c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801830:	ba 00 00 00 00       	mov    $0x0,%edx
  801835:	b8 0e 00 00 00       	mov    $0xe,%eax
  80183a:	89 d1                	mov    %edx,%ecx
  80183c:	89 d3                	mov    %edx,%ebx
  80183e:	89 d7                	mov    %edx,%edi
  801840:	89 d6                	mov    %edx,%esi
  801842:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  801844:	8b 1c 24             	mov    (%esp),%ebx
  801847:	8b 74 24 04          	mov    0x4(%esp),%esi
  80184b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80184f:	89 ec                	mov    %ebp,%esp
  801851:	5d                   	pop    %ebp
  801852:	c3                   	ret    

00801853 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  801853:	55                   	push   %ebp
  801854:	89 e5                	mov    %esp,%ebp
  801856:	83 ec 38             	sub    $0x38,%esp
  801859:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80185c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80185f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801862:	b9 00 00 00 00       	mov    $0x0,%ecx
  801867:	b8 0d 00 00 00       	mov    $0xd,%eax
  80186c:	8b 55 08             	mov    0x8(%ebp),%edx
  80186f:	89 cb                	mov    %ecx,%ebx
  801871:	89 cf                	mov    %ecx,%edi
  801873:	89 ce                	mov    %ecx,%esi
  801875:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801877:	85 c0                	test   %eax,%eax
  801879:	7e 28                	jle    8018a3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  80187b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80187f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  801886:	00 
  801887:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  80188e:	00 
  80188f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801896:	00 
  801897:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  80189e:	e8 5d f2 ff ff       	call   800b00 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  8018a3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8018a6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8018a9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8018ac:	89 ec                	mov    %ebp,%esp
  8018ae:	5d                   	pop    %ebp
  8018af:	c3                   	ret    

008018b0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  8018b0:	55                   	push   %ebp
  8018b1:	89 e5                	mov    %esp,%ebp
  8018b3:	83 ec 38             	sub    $0x38,%esp
  8018b6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8018b9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8018bc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8018bf:	be 00 00 00 00       	mov    $0x0,%esi
  8018c4:	b8 0c 00 00 00       	mov    $0xc,%eax
  8018c9:	8b 7d 14             	mov    0x14(%ebp),%edi
  8018cc:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8018cf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8018d2:	8b 55 08             	mov    0x8(%ebp),%edx
  8018d5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8018d7:	85 c0                	test   %eax,%eax
  8018d9:	7e 28                	jle    801903 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  8018db:	89 44 24 10          	mov    %eax,0x10(%esp)
  8018df:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  8018e6:	00 
  8018e7:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  8018ee:	00 
  8018ef:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8018f6:	00 
  8018f7:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  8018fe:	e8 fd f1 ff ff       	call   800b00 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801903:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801906:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801909:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80190c:	89 ec                	mov    %ebp,%esp
  80190e:	5d                   	pop    %ebp
  80190f:	c3                   	ret    

00801910 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801910:	55                   	push   %ebp
  801911:	89 e5                	mov    %esp,%ebp
  801913:	83 ec 38             	sub    $0x38,%esp
  801916:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801919:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80191c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80191f:	bb 00 00 00 00       	mov    $0x0,%ebx
  801924:	b8 0a 00 00 00       	mov    $0xa,%eax
  801929:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80192c:	8b 55 08             	mov    0x8(%ebp),%edx
  80192f:	89 df                	mov    %ebx,%edi
  801931:	89 de                	mov    %ebx,%esi
  801933:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801935:	85 c0                	test   %eax,%eax
  801937:	7e 28                	jle    801961 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801939:	89 44 24 10          	mov    %eax,0x10(%esp)
  80193d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  801944:	00 
  801945:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  80194c:	00 
  80194d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801954:	00 
  801955:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  80195c:	e8 9f f1 ff ff       	call   800b00 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  801961:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801964:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801967:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80196a:	89 ec                	mov    %ebp,%esp
  80196c:	5d                   	pop    %ebp
  80196d:	c3                   	ret    

0080196e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  80196e:	55                   	push   %ebp
  80196f:	89 e5                	mov    %esp,%ebp
  801971:	83 ec 38             	sub    $0x38,%esp
  801974:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801977:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80197a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80197d:	bb 00 00 00 00       	mov    $0x0,%ebx
  801982:	b8 09 00 00 00       	mov    $0x9,%eax
  801987:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80198a:	8b 55 08             	mov    0x8(%ebp),%edx
  80198d:	89 df                	mov    %ebx,%edi
  80198f:	89 de                	mov    %ebx,%esi
  801991:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801993:	85 c0                	test   %eax,%eax
  801995:	7e 28                	jle    8019bf <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801997:	89 44 24 10          	mov    %eax,0x10(%esp)
  80199b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  8019a2:	00 
  8019a3:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  8019aa:	00 
  8019ab:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8019b2:	00 
  8019b3:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  8019ba:	e8 41 f1 ff ff       	call   800b00 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  8019bf:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8019c2:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8019c5:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8019c8:	89 ec                	mov    %ebp,%esp
  8019ca:	5d                   	pop    %ebp
  8019cb:	c3                   	ret    

008019cc <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  8019cc:	55                   	push   %ebp
  8019cd:	89 e5                	mov    %esp,%ebp
  8019cf:	83 ec 38             	sub    $0x38,%esp
  8019d2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8019d5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8019d8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8019db:	bb 00 00 00 00       	mov    $0x0,%ebx
  8019e0:	b8 08 00 00 00       	mov    $0x8,%eax
  8019e5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8019e8:	8b 55 08             	mov    0x8(%ebp),%edx
  8019eb:	89 df                	mov    %ebx,%edi
  8019ed:	89 de                	mov    %ebx,%esi
  8019ef:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8019f1:	85 c0                	test   %eax,%eax
  8019f3:	7e 28                	jle    801a1d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8019f5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8019f9:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801a00:	00 
  801a01:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  801a08:	00 
  801a09:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801a10:	00 
  801a11:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  801a18:	e8 e3 f0 ff ff       	call   800b00 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  801a1d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801a20:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801a23:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801a26:	89 ec                	mov    %ebp,%esp
  801a28:	5d                   	pop    %ebp
  801a29:	c3                   	ret    

00801a2a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  801a2a:	55                   	push   %ebp
  801a2b:	89 e5                	mov    %esp,%ebp
  801a2d:	83 ec 38             	sub    $0x38,%esp
  801a30:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801a33:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801a36:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801a39:	bb 00 00 00 00       	mov    $0x0,%ebx
  801a3e:	b8 06 00 00 00       	mov    $0x6,%eax
  801a43:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801a46:	8b 55 08             	mov    0x8(%ebp),%edx
  801a49:	89 df                	mov    %ebx,%edi
  801a4b:	89 de                	mov    %ebx,%esi
  801a4d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801a4f:	85 c0                	test   %eax,%eax
  801a51:	7e 28                	jle    801a7b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801a53:	89 44 24 10          	mov    %eax,0x10(%esp)
  801a57:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  801a5e:	00 
  801a5f:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  801a66:	00 
  801a67:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801a6e:	00 
  801a6f:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  801a76:	e8 85 f0 ff ff       	call   800b00 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  801a7b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801a7e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801a81:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801a84:	89 ec                	mov    %ebp,%esp
  801a86:	5d                   	pop    %ebp
  801a87:	c3                   	ret    

00801a88 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801a88:	55                   	push   %ebp
  801a89:	89 e5                	mov    %esp,%ebp
  801a8b:	83 ec 38             	sub    $0x38,%esp
  801a8e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801a91:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801a94:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801a97:	b8 05 00 00 00       	mov    $0x5,%eax
  801a9c:	8b 75 18             	mov    0x18(%ebp),%esi
  801a9f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801aa2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801aa5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801aa8:	8b 55 08             	mov    0x8(%ebp),%edx
  801aab:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801aad:	85 c0                	test   %eax,%eax
  801aaf:	7e 28                	jle    801ad9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801ab1:	89 44 24 10          	mov    %eax,0x10(%esp)
  801ab5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  801abc:	00 
  801abd:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  801ac4:	00 
  801ac5:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801acc:	00 
  801acd:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  801ad4:	e8 27 f0 ff ff       	call   800b00 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801ad9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801adc:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801adf:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801ae2:	89 ec                	mov    %ebp,%esp
  801ae4:	5d                   	pop    %ebp
  801ae5:	c3                   	ret    

00801ae6 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801ae6:	55                   	push   %ebp
  801ae7:	89 e5                	mov    %esp,%ebp
  801ae9:	83 ec 38             	sub    $0x38,%esp
  801aec:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801aef:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801af2:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801af5:	be 00 00 00 00       	mov    $0x0,%esi
  801afa:	b8 04 00 00 00       	mov    $0x4,%eax
  801aff:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801b02:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801b05:	8b 55 08             	mov    0x8(%ebp),%edx
  801b08:	89 f7                	mov    %esi,%edi
  801b0a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801b0c:	85 c0                	test   %eax,%eax
  801b0e:	7e 28                	jle    801b38 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801b10:	89 44 24 10          	mov    %eax,0x10(%esp)
  801b14:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  801b1b:	00 
  801b1c:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  801b23:	00 
  801b24:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801b2b:	00 
  801b2c:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  801b33:	e8 c8 ef ff ff       	call   800b00 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801b38:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801b3b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801b3e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801b41:	89 ec                	mov    %ebp,%esp
  801b43:	5d                   	pop    %ebp
  801b44:	c3                   	ret    

00801b45 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801b45:	55                   	push   %ebp
  801b46:	89 e5                	mov    %esp,%ebp
  801b48:	83 ec 0c             	sub    $0xc,%esp
  801b4b:	89 1c 24             	mov    %ebx,(%esp)
  801b4e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801b52:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801b56:	ba 00 00 00 00       	mov    $0x0,%edx
  801b5b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801b60:	89 d1                	mov    %edx,%ecx
  801b62:	89 d3                	mov    %edx,%ebx
  801b64:	89 d7                	mov    %edx,%edi
  801b66:	89 d6                	mov    %edx,%esi
  801b68:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  801b6a:	8b 1c 24             	mov    (%esp),%ebx
  801b6d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801b71:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801b75:	89 ec                	mov    %ebp,%esp
  801b77:	5d                   	pop    %ebp
  801b78:	c3                   	ret    

00801b79 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801b79:	55                   	push   %ebp
  801b7a:	89 e5                	mov    %esp,%ebp
  801b7c:	83 ec 0c             	sub    $0xc,%esp
  801b7f:	89 1c 24             	mov    %ebx,(%esp)
  801b82:	89 74 24 04          	mov    %esi,0x4(%esp)
  801b86:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801b8a:	ba 00 00 00 00       	mov    $0x0,%edx
  801b8f:	b8 02 00 00 00       	mov    $0x2,%eax
  801b94:	89 d1                	mov    %edx,%ecx
  801b96:	89 d3                	mov    %edx,%ebx
  801b98:	89 d7                	mov    %edx,%edi
  801b9a:	89 d6                	mov    %edx,%esi
  801b9c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  801b9e:	8b 1c 24             	mov    (%esp),%ebx
  801ba1:	8b 74 24 04          	mov    0x4(%esp),%esi
  801ba5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801ba9:	89 ec                	mov    %ebp,%esp
  801bab:	5d                   	pop    %ebp
  801bac:	c3                   	ret    

00801bad <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  801bad:	55                   	push   %ebp
  801bae:	89 e5                	mov    %esp,%ebp
  801bb0:	83 ec 38             	sub    $0x38,%esp
  801bb3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801bb6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801bb9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801bbc:	b9 00 00 00 00       	mov    $0x0,%ecx
  801bc1:	b8 03 00 00 00       	mov    $0x3,%eax
  801bc6:	8b 55 08             	mov    0x8(%ebp),%edx
  801bc9:	89 cb                	mov    %ecx,%ebx
  801bcb:	89 cf                	mov    %ecx,%edi
  801bcd:	89 ce                	mov    %ecx,%esi
  801bcf:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801bd1:	85 c0                	test   %eax,%eax
  801bd3:	7e 28                	jle    801bfd <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801bd5:	89 44 24 10          	mov    %eax,0x10(%esp)
  801bd9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801be0:	00 
  801be1:	c7 44 24 08 3b 43 80 	movl   $0x80433b,0x8(%esp)
  801be8:	00 
  801be9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801bf0:	00 
  801bf1:	c7 04 24 58 43 80 00 	movl   $0x804358,(%esp)
  801bf8:	e8 03 ef ff ff       	call   800b00 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  801bfd:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801c00:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801c03:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801c06:	89 ec                	mov    %ebp,%esp
  801c08:	5d                   	pop    %ebp
  801c09:	c3                   	ret    
  801c0a:	00 00                	add    %al,(%eax)
  801c0c:	00 00                	add    %al,(%eax)
	...

00801c10 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801c10:	55                   	push   %ebp
  801c11:	89 e5                	mov    %esp,%ebp
  801c13:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801c16:	c7 44 24 08 66 43 80 	movl   $0x804366,0x8(%esp)
  801c1d:	00 
  801c1e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  801c25:	00 
  801c26:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801c2d:	e8 ce ee ff ff       	call   800b00 <_panic>

00801c32 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801c32:	55                   	push   %ebp
  801c33:	89 e5                	mov    %esp,%ebp
  801c35:	57                   	push   %edi
  801c36:	56                   	push   %esi
  801c37:	53                   	push   %ebx
  801c38:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  801c3b:	c7 04 24 9c 1e 80 00 	movl   $0x801e9c,(%esp)
  801c42:	e8 79 1d 00 00       	call   8039c0 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801c47:	ba 07 00 00 00       	mov    $0x7,%edx
  801c4c:	89 d0                	mov    %edx,%eax
  801c4e:	cd 30                	int    $0x30
  801c50:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  801c53:	85 c0                	test   %eax,%eax
  801c55:	79 20                	jns    801c77 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  801c57:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801c5b:	c7 44 24 08 ec 43 80 	movl   $0x8043ec,0x8(%esp)
  801c62:	00 
  801c63:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  801c6a:	00 
  801c6b:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801c72:	e8 89 ee ff ff       	call   800b00 <_panic>
    } else if (childId>0) {
  801c77:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801c7b:	0f 8e f3 01 00 00    	jle    801e74 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  801c81:	c7 44 24 04 30 3a 80 	movl   $0x803a30,0x4(%esp)
  801c88:	00 
  801c89:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801c8c:	89 04 24             	mov    %eax,(%esp)
  801c8f:	e8 7c fc ff ff       	call   801910 <sys_env_set_pgfault_upcall>
  801c94:	85 c0                	test   %eax,%eax
  801c96:	74 20                	je     801cb8 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  801c98:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801c9c:	c7 44 24 08 10 44 80 	movl   $0x804410,0x8(%esp)
  801ca3:	00 
  801ca4:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  801cab:	00 
  801cac:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801cb3:	e8 48 ee ff ff       	call   800b00 <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  801cb8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801cbf:	00 
  801cc0:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801cc7:	ee 
  801cc8:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801ccb:	89 04 24             	mov    %eax,(%esp)
  801cce:	e8 13 fe ff ff       	call   801ae6 <sys_page_alloc>
  801cd3:	85 c0                	test   %eax,%eax
  801cd5:	79 20                	jns    801cf7 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801cd7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801cdb:	c7 44 24 08 40 44 80 	movl   $0x804440,0x8(%esp)
  801ce2:	00 
  801ce3:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  801cea:	00 
  801ceb:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801cf2:	e8 09 ee ff ff       	call   800b00 <_panic>
  801cf7:	be 00 00 80 00       	mov    $0x800000,%esi
  801cfc:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801d01:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801d06:	89 f0                	mov    %esi,%eax
  801d08:	c1 e8 16             	shr    $0x16,%eax
  801d0b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  801d0e:	a8 01                	test   $0x1,%al
  801d10:	0f 84 13 01 00 00    	je     801e29 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801d16:	89 f0                	mov    %esi,%eax
  801d18:	c1 e8 0c             	shr    $0xc,%eax
  801d1b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801d22:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801d25:	25 07 0e 00 00       	and    $0xe07,%eax
  801d2a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  801d2d:	e8 47 fe ff ff       	call   801b79 <sys_getenvid>
  801d32:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  801d35:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  801d39:	0f 84 ea 00 00 00    	je     801e29 <fork+0x1f7>
  801d3f:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  801d46:	0f 84 9d 00 00 00    	je     801de9 <fork+0x1b7>
  801d4c:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  801d53:	0f 85 90 00 00 00    	jne    801de9 <fork+0x1b7>
    perm    &= (~PTE_W);
  801d59:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801d5c:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  801d5f:	80 cc 08             	or     $0x8,%ah
  801d62:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801d65:	89 75 e0             	mov    %esi,-0x20(%ebp)
  801d68:	89 44 24 10          	mov    %eax,0x10(%esp)
  801d6c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801d70:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801d73:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d77:	89 74 24 04          	mov    %esi,0x4(%esp)
  801d7b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801d7e:	89 04 24             	mov    %eax,(%esp)
  801d81:	e8 02 fd ff ff       	call   801a88 <sys_page_map>
  801d86:	85 c0                	test   %eax,%eax
  801d88:	79 1b                	jns    801da5 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  801d8a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801d8e:	89 74 24 08          	mov    %esi,0x8(%esp)
  801d92:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801d95:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d99:	c7 04 24 68 44 80 00 	movl   $0x804468,(%esp)
  801da0:	e8 20 ee ff ff       	call   800bc5 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  801da5:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801da8:	89 44 24 10          	mov    %eax,0x10(%esp)
  801dac:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801daf:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801db3:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801db6:	89 44 24 08          	mov    %eax,0x8(%esp)
  801dba:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801dbd:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dc1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801dc4:	89 04 24             	mov    %eax,(%esp)
  801dc7:	e8 bc fc ff ff       	call   801a88 <sys_page_map>
  801dcc:	85 c0                	test   %eax,%eax
  801dce:	79 59                	jns    801e29 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801dd0:	89 44 24 08          	mov    %eax,0x8(%esp)
  801dd4:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801dd7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ddb:	c7 04 24 a8 44 80 00 	movl   $0x8044a8,(%esp)
  801de2:	e8 de ed ff ff       	call   800bc5 <cprintf>
  801de7:	eb 40                	jmp    801e29 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801de9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801dec:	89 44 24 10          	mov    %eax,0x10(%esp)
  801df0:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801df4:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801df7:	89 44 24 08          	mov    %eax,0x8(%esp)
  801dfb:	89 74 24 04          	mov    %esi,0x4(%esp)
  801dff:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801e02:	89 04 24             	mov    %eax,(%esp)
  801e05:	e8 7e fc ff ff       	call   801a88 <sys_page_map>
  801e0a:	85 c0                	test   %eax,%eax
  801e0c:	79 1b                	jns    801e29 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  801e0e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801e12:	89 74 24 08          	mov    %esi,0x8(%esp)
  801e16:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801e19:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e1d:	c7 04 24 68 44 80 00 	movl   $0x804468,(%esp)
  801e24:	e8 9c ed ff ff       	call   800bc5 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  801e29:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  801e2f:	89 de                	mov    %ebx,%esi
  801e31:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  801e37:	0f 85 c9 fe ff ff    	jne    801d06 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  801e3d:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801e44:	00 
  801e45:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801e48:	89 04 24             	mov    %eax,(%esp)
  801e4b:	e8 7c fb ff ff       	call   8019cc <sys_env_set_status>
  801e50:	85 c0                	test   %eax,%eax
  801e52:	79 3d                	jns    801e91 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  801e54:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801e58:	c7 44 24 08 dc 44 80 	movl   $0x8044dc,0x8(%esp)
  801e5f:	00 
  801e60:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  801e67:	00 
  801e68:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801e6f:	e8 8c ec ff ff       	call   800b00 <_panic>
    } else if (childId==0) {
  801e74:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801e78:	75 17                	jne    801e91 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  801e7a:	e8 fa fc ff ff       	call   801b79 <sys_getenvid>
  801e7f:	25 ff 03 00 00       	and    $0x3ff,%eax
  801e84:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801e87:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  801e8c:	a3 a0 84 80 00       	mov    %eax,0x8084a0
    }
    return childId;
}
  801e91:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801e94:	83 c4 3c             	add    $0x3c,%esp
  801e97:	5b                   	pop    %ebx
  801e98:	5e                   	pop    %esi
  801e99:	5f                   	pop    %edi
  801e9a:	5d                   	pop    %ebp
  801e9b:	c3                   	ret    

00801e9c <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  801e9c:	55                   	push   %ebp
  801e9d:	89 e5                	mov    %esp,%ebp
  801e9f:	57                   	push   %edi
  801ea0:	56                   	push   %esi
  801ea1:	53                   	push   %ebx
  801ea2:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  801ea5:	8b 45 08             	mov    0x8(%ebp),%eax
  801ea8:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  801eaa:	8b 50 04             	mov    0x4(%eax),%edx
  801ead:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  801eb0:	89 fe                	mov    %edi,%esi
  801eb2:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  801eb8:	e8 bc fc ff ff       	call   801b79 <sys_getenvid>
  801ebd:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  801ebf:	89 f2                	mov    %esi,%edx
  801ec1:	89 f0                	mov    %esi,%eax
  801ec3:	c1 e8 16             	shr    $0x16,%eax
  801ec6:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801ecd:	a8 01                	test   $0x1,%al
  801ecf:	74 3e                	je     801f0f <pgfault+0x73>
  801ed1:	c1 ea 0c             	shr    $0xc,%edx
  801ed4:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801edb:	a8 01                	test   $0x1,%al
  801edd:	74 30                	je     801f0f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  801edf:	c1 ef 0c             	shr    $0xc,%edi
  801ee2:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801ee9:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  801eef:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801ef2:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801ef6:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  801efd:	00 
  801efe:	89 1c 24             	mov    %ebx,(%esp)
  801f01:	e8 e0 fb ff ff       	call   801ae6 <sys_page_alloc>
  801f06:	85 c0                	test   %eax,%eax
  801f08:	74 46                	je     801f50 <pgfault+0xb4>
  801f0a:	e9 cd 00 00 00       	jmp    801fdc <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  801f0f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801f12:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801f16:	8b 55 08             	mov    0x8(%ebp),%edx
  801f19:	8b 42 28             	mov    0x28(%edx),%eax
  801f1c:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f20:	89 74 24 04          	mov    %esi,0x4(%esp)
  801f24:	c7 04 24 fc 44 80 00 	movl   $0x8044fc,(%esp)
  801f2b:	e8 95 ec ff ff       	call   800bc5 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  801f30:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801f34:	c7 44 24 08 87 43 80 	movl   $0x804387,0x8(%esp)
  801f3b:	00 
  801f3c:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  801f43:	00 
  801f44:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801f4b:	e8 b0 eb ff ff       	call   800b00 <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  801f50:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  801f57:	00 
  801f58:	89 74 24 04          	mov    %esi,0x4(%esp)
  801f5c:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  801f63:	e8 dd f5 ff ff       	call   801545 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  801f68:	89 7c 24 10          	mov    %edi,0x10(%esp)
  801f6c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801f70:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801f74:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  801f7b:	00 
  801f7c:	89 1c 24             	mov    %ebx,(%esp)
  801f7f:	e8 04 fb ff ff       	call   801a88 <sys_page_map>
  801f84:	85 c0                	test   %eax,%eax
  801f86:	74 20                	je     801fa8 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  801f88:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801f8c:	c7 44 24 08 99 43 80 	movl   $0x804399,0x8(%esp)
  801f93:	00 
  801f94:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  801f9b:	00 
  801f9c:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801fa3:	e8 58 eb ff ff       	call   800b00 <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  801fa8:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  801faf:	00 
  801fb0:	89 1c 24             	mov    %ebx,(%esp)
  801fb3:	e8 72 fa ff ff       	call   801a2a <sys_page_unmap>
  801fb8:	85 c0                	test   %eax,%eax
  801fba:	74 40                	je     801ffc <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  801fbc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801fc0:	c7 44 24 08 b4 43 80 	movl   $0x8043b4,0x8(%esp)
  801fc7:	00 
  801fc8:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  801fcf:	00 
  801fd0:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801fd7:	e8 24 eb ff ff       	call   800b00 <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  801fdc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801fe0:	c7 44 24 08 d1 43 80 	movl   $0x8043d1,0x8(%esp)
  801fe7:	00 
  801fe8:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  801fef:	00 
  801ff0:	c7 04 24 7c 43 80 00 	movl   $0x80437c,(%esp)
  801ff7:	e8 04 eb ff ff       	call   800b00 <_panic>
}
  801ffc:	83 c4 3c             	add    $0x3c,%esp
  801fff:	5b                   	pop    %ebx
  802000:	5e                   	pop    %esi
  802001:	5f                   	pop    %edi
  802002:	5d                   	pop    %ebp
  802003:	c3                   	ret    
	...

00802010 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  802010:	55                   	push   %ebp
  802011:	89 e5                	mov    %esp,%ebp
  802013:	8b 45 08             	mov    0x8(%ebp),%eax
  802016:	05 00 00 00 30       	add    $0x30000000,%eax
  80201b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80201e:	5d                   	pop    %ebp
  80201f:	c3                   	ret    

00802020 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  802020:	55                   	push   %ebp
  802021:	89 e5                	mov    %esp,%ebp
  802023:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  802026:	8b 45 08             	mov    0x8(%ebp),%eax
  802029:	89 04 24             	mov    %eax,(%esp)
  80202c:	e8 df ff ff ff       	call   802010 <fd2num>
  802031:	05 20 00 0d 00       	add    $0xd0020,%eax
  802036:	c1 e0 0c             	shl    $0xc,%eax
}
  802039:	c9                   	leave  
  80203a:	c3                   	ret    

0080203b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80203b:	55                   	push   %ebp
  80203c:	89 e5                	mov    %esp,%ebp
  80203e:	57                   	push   %edi
  80203f:	56                   	push   %esi
  802040:	53                   	push   %ebx
  802041:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  802044:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  802049:	a8 01                	test   $0x1,%al
  80204b:	74 36                	je     802083 <fd_alloc+0x48>
  80204d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  802052:	a8 01                	test   $0x1,%al
  802054:	74 2d                	je     802083 <fd_alloc+0x48>
  802056:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80205b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  802060:	be 00 00 40 ef       	mov    $0xef400000,%esi
  802065:	89 c3                	mov    %eax,%ebx
  802067:	89 c2                	mov    %eax,%edx
  802069:	c1 ea 16             	shr    $0x16,%edx
  80206c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80206f:	f6 c2 01             	test   $0x1,%dl
  802072:	74 14                	je     802088 <fd_alloc+0x4d>
  802074:	89 c2                	mov    %eax,%edx
  802076:	c1 ea 0c             	shr    $0xc,%edx
  802079:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80207c:	f6 c2 01             	test   $0x1,%dl
  80207f:	75 10                	jne    802091 <fd_alloc+0x56>
  802081:	eb 05                	jmp    802088 <fd_alloc+0x4d>
  802083:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  802088:	89 1f                	mov    %ebx,(%edi)
  80208a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80208f:	eb 17                	jmp    8020a8 <fd_alloc+0x6d>
  802091:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  802096:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80209b:	75 c8                	jne    802065 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80209d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8020a3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8020a8:	5b                   	pop    %ebx
  8020a9:	5e                   	pop    %esi
  8020aa:	5f                   	pop    %edi
  8020ab:	5d                   	pop    %ebp
  8020ac:	c3                   	ret    

008020ad <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8020ad:	55                   	push   %ebp
  8020ae:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8020b0:	8b 45 08             	mov    0x8(%ebp),%eax
  8020b3:	83 f8 1f             	cmp    $0x1f,%eax
  8020b6:	77 36                	ja     8020ee <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8020b8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8020bd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  8020c0:	89 c2                	mov    %eax,%edx
  8020c2:	c1 ea 16             	shr    $0x16,%edx
  8020c5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8020cc:	f6 c2 01             	test   $0x1,%dl
  8020cf:	74 1d                	je     8020ee <fd_lookup+0x41>
  8020d1:	89 c2                	mov    %eax,%edx
  8020d3:	c1 ea 0c             	shr    $0xc,%edx
  8020d6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8020dd:	f6 c2 01             	test   $0x1,%dl
  8020e0:	74 0c                	je     8020ee <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8020e2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8020e5:	89 02                	mov    %eax,(%edx)
  8020e7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8020ec:	eb 05                	jmp    8020f3 <fd_lookup+0x46>
  8020ee:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8020f3:	5d                   	pop    %ebp
  8020f4:	c3                   	ret    

008020f5 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  8020f5:	55                   	push   %ebp
  8020f6:	89 e5                	mov    %esp,%ebp
  8020f8:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8020fb:	8d 45 fc             	lea    -0x4(%ebp),%eax
  8020fe:	89 44 24 04          	mov    %eax,0x4(%esp)
  802102:	8b 45 08             	mov    0x8(%ebp),%eax
  802105:	89 04 24             	mov    %eax,(%esp)
  802108:	e8 a0 ff ff ff       	call   8020ad <fd_lookup>
  80210d:	85 c0                	test   %eax,%eax
  80210f:	78 0e                	js     80211f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  802111:	8b 45 fc             	mov    -0x4(%ebp),%eax
  802114:	8b 55 0c             	mov    0xc(%ebp),%edx
  802117:	89 50 04             	mov    %edx,0x4(%eax)
  80211a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80211f:	c9                   	leave  
  802120:	c3                   	ret    

00802121 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  802121:	55                   	push   %ebp
  802122:	89 e5                	mov    %esp,%ebp
  802124:	56                   	push   %esi
  802125:	53                   	push   %ebx
  802126:	83 ec 10             	sub    $0x10,%esp
  802129:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80212c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80212f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  802134:	b8 20 80 80 00       	mov    $0x808020,%eax
  802139:	39 0d 20 80 80 00    	cmp    %ecx,0x808020
  80213f:	75 11                	jne    802152 <dev_lookup+0x31>
  802141:	eb 04                	jmp    802147 <dev_lookup+0x26>
  802143:	39 08                	cmp    %ecx,(%eax)
  802145:	75 10                	jne    802157 <dev_lookup+0x36>
			*dev = devtab[i];
  802147:	89 03                	mov    %eax,(%ebx)
  802149:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80214e:	66 90                	xchg   %ax,%ax
  802150:	eb 36                	jmp    802188 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  802152:	be a4 45 80 00       	mov    $0x8045a4,%esi
  802157:	83 c2 01             	add    $0x1,%edx
  80215a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80215d:	85 c0                	test   %eax,%eax
  80215f:	75 e2                	jne    802143 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  802161:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  802166:	8b 40 4c             	mov    0x4c(%eax),%eax
  802169:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80216d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802171:	c7 04 24 28 45 80 00 	movl   $0x804528,(%esp)
  802178:	e8 48 ea ff ff       	call   800bc5 <cprintf>
	*dev = 0;
  80217d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  802183:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  802188:	83 c4 10             	add    $0x10,%esp
  80218b:	5b                   	pop    %ebx
  80218c:	5e                   	pop    %esi
  80218d:	5d                   	pop    %ebp
  80218e:	c3                   	ret    

0080218f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80218f:	55                   	push   %ebp
  802190:	89 e5                	mov    %esp,%ebp
  802192:	53                   	push   %ebx
  802193:	83 ec 24             	sub    $0x24,%esp
  802196:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  802199:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80219c:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021a0:	8b 45 08             	mov    0x8(%ebp),%eax
  8021a3:	89 04 24             	mov    %eax,(%esp)
  8021a6:	e8 02 ff ff ff       	call   8020ad <fd_lookup>
  8021ab:	85 c0                	test   %eax,%eax
  8021ad:	78 53                	js     802202 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8021af:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8021b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021b6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8021b9:	8b 00                	mov    (%eax),%eax
  8021bb:	89 04 24             	mov    %eax,(%esp)
  8021be:	e8 5e ff ff ff       	call   802121 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8021c3:	85 c0                	test   %eax,%eax
  8021c5:	78 3b                	js     802202 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  8021c7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8021cc:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8021cf:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8021d3:	74 2d                	je     802202 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8021d5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8021d8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8021df:	00 00 00 
	stat->st_isdir = 0;
  8021e2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8021e9:	00 00 00 
	stat->st_dev = dev;
  8021ec:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021ef:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  8021f5:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8021f9:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8021fc:	89 14 24             	mov    %edx,(%esp)
  8021ff:	ff 50 14             	call   *0x14(%eax)
}
  802202:	83 c4 24             	add    $0x24,%esp
  802205:	5b                   	pop    %ebx
  802206:	5d                   	pop    %ebp
  802207:	c3                   	ret    

00802208 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  802208:	55                   	push   %ebp
  802209:	89 e5                	mov    %esp,%ebp
  80220b:	53                   	push   %ebx
  80220c:	83 ec 24             	sub    $0x24,%esp
  80220f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  802212:	8d 45 f0             	lea    -0x10(%ebp),%eax
  802215:	89 44 24 04          	mov    %eax,0x4(%esp)
  802219:	89 1c 24             	mov    %ebx,(%esp)
  80221c:	e8 8c fe ff ff       	call   8020ad <fd_lookup>
  802221:	85 c0                	test   %eax,%eax
  802223:	78 5f                	js     802284 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  802225:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802228:	89 44 24 04          	mov    %eax,0x4(%esp)
  80222c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80222f:	8b 00                	mov    (%eax),%eax
  802231:	89 04 24             	mov    %eax,(%esp)
  802234:	e8 e8 fe ff ff       	call   802121 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  802239:	85 c0                	test   %eax,%eax
  80223b:	78 47                	js     802284 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80223d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802240:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  802244:	75 23                	jne    802269 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  802246:	a1 a0 84 80 00       	mov    0x8084a0,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80224b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80224e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802252:	89 44 24 04          	mov    %eax,0x4(%esp)
  802256:	c7 04 24 48 45 80 00 	movl   $0x804548,(%esp)
  80225d:	e8 63 e9 ff ff       	call   800bc5 <cprintf>
  802262:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  802267:	eb 1b                	jmp    802284 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  802269:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80226c:	8b 48 18             	mov    0x18(%eax),%ecx
  80226f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802274:	85 c9                	test   %ecx,%ecx
  802276:	74 0c                	je     802284 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  802278:	8b 45 0c             	mov    0xc(%ebp),%eax
  80227b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80227f:	89 14 24             	mov    %edx,(%esp)
  802282:	ff d1                	call   *%ecx
}
  802284:	83 c4 24             	add    $0x24,%esp
  802287:	5b                   	pop    %ebx
  802288:	5d                   	pop    %ebp
  802289:	c3                   	ret    

0080228a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80228a:	55                   	push   %ebp
  80228b:	89 e5                	mov    %esp,%ebp
  80228d:	53                   	push   %ebx
  80228e:	83 ec 24             	sub    $0x24,%esp
  802291:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  802294:	8d 45 f0             	lea    -0x10(%ebp),%eax
  802297:	89 44 24 04          	mov    %eax,0x4(%esp)
  80229b:	89 1c 24             	mov    %ebx,(%esp)
  80229e:	e8 0a fe ff ff       	call   8020ad <fd_lookup>
  8022a3:	85 c0                	test   %eax,%eax
  8022a5:	78 66                	js     80230d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8022a7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8022aa:	89 44 24 04          	mov    %eax,0x4(%esp)
  8022ae:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8022b1:	8b 00                	mov    (%eax),%eax
  8022b3:	89 04 24             	mov    %eax,(%esp)
  8022b6:	e8 66 fe ff ff       	call   802121 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8022bb:	85 c0                	test   %eax,%eax
  8022bd:	78 4e                	js     80230d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8022bf:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8022c2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8022c6:	75 23                	jne    8022eb <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  8022c8:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  8022cd:	8b 40 4c             	mov    0x4c(%eax),%eax
  8022d0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8022d4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8022d8:	c7 04 24 69 45 80 00 	movl   $0x804569,(%esp)
  8022df:	e8 e1 e8 ff ff       	call   800bc5 <cprintf>
  8022e4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8022e9:	eb 22                	jmp    80230d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8022eb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8022ee:	8b 48 0c             	mov    0xc(%eax),%ecx
  8022f1:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8022f6:	85 c9                	test   %ecx,%ecx
  8022f8:	74 13                	je     80230d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  8022fa:	8b 45 10             	mov    0x10(%ebp),%eax
  8022fd:	89 44 24 08          	mov    %eax,0x8(%esp)
  802301:	8b 45 0c             	mov    0xc(%ebp),%eax
  802304:	89 44 24 04          	mov    %eax,0x4(%esp)
  802308:	89 14 24             	mov    %edx,(%esp)
  80230b:	ff d1                	call   *%ecx
}
  80230d:	83 c4 24             	add    $0x24,%esp
  802310:	5b                   	pop    %ebx
  802311:	5d                   	pop    %ebp
  802312:	c3                   	ret    

00802313 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  802313:	55                   	push   %ebp
  802314:	89 e5                	mov    %esp,%ebp
  802316:	57                   	push   %edi
  802317:	56                   	push   %esi
  802318:	53                   	push   %ebx
  802319:	83 ec 2c             	sub    $0x2c,%esp
  80231c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80231f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  802322:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802325:	89 44 24 04          	mov    %eax,0x4(%esp)
  802329:	89 1c 24             	mov    %ebx,(%esp)
  80232c:	e8 7c fd ff ff       	call   8020ad <fd_lookup>
  802331:	85 c0                	test   %eax,%eax
  802333:	0f 88 b0 00 00 00    	js     8023e9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  802339:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80233c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802340:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802343:	8b 00                	mov    (%eax),%eax
  802345:	89 04 24             	mov    %eax,(%esp)
  802348:	e8 d4 fd ff ff       	call   802121 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80234d:	85 c0                	test   %eax,%eax
  80234f:	0f 88 94 00 00 00    	js     8023e9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  802355:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802358:	8b 40 08             	mov    0x8(%eax),%eax
  80235b:	83 e0 03             	and    $0x3,%eax
  80235e:	83 f8 01             	cmp    $0x1,%eax
  802361:	75 23                	jne    802386 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  802363:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  802368:	8b 40 4c             	mov    0x4c(%eax),%eax
  80236b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80236f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802373:	c7 04 24 86 45 80 00 	movl   $0x804586,(%esp)
  80237a:	e8 46 e8 ff ff       	call   800bc5 <cprintf>
  80237f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  802384:	eb 63                	jmp    8023e9 <read+0xd6>
	}
	if (!dev->dev_read)
  802386:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80238b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80238e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  802392:	74 55                	je     8023e9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  802394:	ba 00 00 00 00       	mov    $0x0,%edx
  802399:	bb 00 00 00 00       	mov    $0x0,%ebx
  80239e:	b8 00 00 00 00       	mov    $0x0,%eax
  8023a3:	85 f6                	test   %esi,%esi
  8023a5:	74 42                	je     8023e9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  8023a7:	bf 00 10 00 00       	mov    $0x1000,%edi
  8023ac:	89 f0                	mov    %esi,%eax
  8023ae:	29 d0                	sub    %edx,%eax
  8023b0:	89 c1                	mov    %eax,%ecx
  8023b2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8023b8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8023bd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  8023c0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8023c4:	03 55 0c             	add    0xc(%ebp),%edx
  8023c7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8023cb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8023ce:	89 04 24             	mov    %eax,(%esp)
  8023d1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8023d4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8023d7:	85 c0                	test   %eax,%eax
  8023d9:	78 0e                	js     8023e9 <read+0xd6>
			return m;
		if (m == 0)
  8023db:	85 c0                	test   %eax,%eax
  8023dd:	74 08                	je     8023e7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8023df:	01 c3                	add    %eax,%ebx
  8023e1:	89 da                	mov    %ebx,%edx
  8023e3:	39 f3                	cmp    %esi,%ebx
  8023e5:	72 c5                	jb     8023ac <read+0x99>
  8023e7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8023e9:	83 c4 2c             	add    $0x2c,%esp
  8023ec:	5b                   	pop    %ebx
  8023ed:	5e                   	pop    %esi
  8023ee:	5f                   	pop    %edi
  8023ef:	5d                   	pop    %ebp
  8023f0:	c3                   	ret    

008023f1 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  8023f1:	55                   	push   %ebp
  8023f2:	89 e5                	mov    %esp,%ebp
  8023f4:	57                   	push   %edi
  8023f5:	56                   	push   %esi
  8023f6:	53                   	push   %ebx
  8023f7:	83 ec 1c             	sub    $0x1c,%esp
  8023fa:	8b 7d 08             	mov    0x8(%ebp),%edi
  8023fd:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  802400:	ba 00 00 00 00       	mov    $0x0,%edx
  802405:	bb 00 00 00 00       	mov    $0x0,%ebx
  80240a:	b8 00 00 00 00       	mov    $0x0,%eax
  80240f:	85 f6                	test   %esi,%esi
  802411:	74 29                	je     80243c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  802413:	89 f0                	mov    %esi,%eax
  802415:	29 d0                	sub    %edx,%eax
  802417:	89 44 24 08          	mov    %eax,0x8(%esp)
  80241b:	03 55 0c             	add    0xc(%ebp),%edx
  80241e:	89 54 24 04          	mov    %edx,0x4(%esp)
  802422:	89 3c 24             	mov    %edi,(%esp)
  802425:	e8 e9 fe ff ff       	call   802313 <read>
		if (m < 0)
  80242a:	85 c0                	test   %eax,%eax
  80242c:	78 0e                	js     80243c <readn+0x4b>
			return m;
		if (m == 0)
  80242e:	85 c0                	test   %eax,%eax
  802430:	74 08                	je     80243a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  802432:	01 c3                	add    %eax,%ebx
  802434:	89 da                	mov    %ebx,%edx
  802436:	39 f3                	cmp    %esi,%ebx
  802438:	72 d9                	jb     802413 <readn+0x22>
  80243a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80243c:	83 c4 1c             	add    $0x1c,%esp
  80243f:	5b                   	pop    %ebx
  802440:	5e                   	pop    %esi
  802441:	5f                   	pop    %edi
  802442:	5d                   	pop    %ebp
  802443:	c3                   	ret    

00802444 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  802444:	55                   	push   %ebp
  802445:	89 e5                	mov    %esp,%ebp
  802447:	83 ec 28             	sub    $0x28,%esp
  80244a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80244d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  802450:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  802453:	89 34 24             	mov    %esi,(%esp)
  802456:	e8 b5 fb ff ff       	call   802010 <fd2num>
  80245b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80245e:	89 54 24 04          	mov    %edx,0x4(%esp)
  802462:	89 04 24             	mov    %eax,(%esp)
  802465:	e8 43 fc ff ff       	call   8020ad <fd_lookup>
  80246a:	89 c3                	mov    %eax,%ebx
  80246c:	85 c0                	test   %eax,%eax
  80246e:	78 05                	js     802475 <fd_close+0x31>
  802470:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  802473:	74 0e                	je     802483 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  802475:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  802479:	b8 00 00 00 00       	mov    $0x0,%eax
  80247e:	0f 44 d8             	cmove  %eax,%ebx
  802481:	eb 3d                	jmp    8024c0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  802483:	8d 45 f0             	lea    -0x10(%ebp),%eax
  802486:	89 44 24 04          	mov    %eax,0x4(%esp)
  80248a:	8b 06                	mov    (%esi),%eax
  80248c:	89 04 24             	mov    %eax,(%esp)
  80248f:	e8 8d fc ff ff       	call   802121 <dev_lookup>
  802494:	89 c3                	mov    %eax,%ebx
  802496:	85 c0                	test   %eax,%eax
  802498:	78 16                	js     8024b0 <fd_close+0x6c>
		if (dev->dev_close)
  80249a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80249d:	8b 40 10             	mov    0x10(%eax),%eax
  8024a0:	bb 00 00 00 00       	mov    $0x0,%ebx
  8024a5:	85 c0                	test   %eax,%eax
  8024a7:	74 07                	je     8024b0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  8024a9:	89 34 24             	mov    %esi,(%esp)
  8024ac:	ff d0                	call   *%eax
  8024ae:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  8024b0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8024b4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024bb:	e8 6a f5 ff ff       	call   801a2a <sys_page_unmap>
	return r;
}
  8024c0:	89 d8                	mov    %ebx,%eax
  8024c2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8024c5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8024c8:	89 ec                	mov    %ebp,%esp
  8024ca:	5d                   	pop    %ebp
  8024cb:	c3                   	ret    

008024cc <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  8024cc:	55                   	push   %ebp
  8024cd:	89 e5                	mov    %esp,%ebp
  8024cf:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8024d2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8024d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024d9:	8b 45 08             	mov    0x8(%ebp),%eax
  8024dc:	89 04 24             	mov    %eax,(%esp)
  8024df:	e8 c9 fb ff ff       	call   8020ad <fd_lookup>
  8024e4:	85 c0                	test   %eax,%eax
  8024e6:	78 13                	js     8024fb <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  8024e8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8024ef:	00 
  8024f0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8024f3:	89 04 24             	mov    %eax,(%esp)
  8024f6:	e8 49 ff ff ff       	call   802444 <fd_close>
}
  8024fb:	c9                   	leave  
  8024fc:	c3                   	ret    

008024fd <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  8024fd:	55                   	push   %ebp
  8024fe:	89 e5                	mov    %esp,%ebp
  802500:	83 ec 18             	sub    $0x18,%esp
  802503:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802506:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  802509:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802510:	00 
  802511:	8b 45 08             	mov    0x8(%ebp),%eax
  802514:	89 04 24             	mov    %eax,(%esp)
  802517:	e8 80 03 00 00       	call   80289c <open>
  80251c:	89 c3                	mov    %eax,%ebx
  80251e:	85 c0                	test   %eax,%eax
  802520:	78 1b                	js     80253d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  802522:	8b 45 0c             	mov    0xc(%ebp),%eax
  802525:	89 44 24 04          	mov    %eax,0x4(%esp)
  802529:	89 1c 24             	mov    %ebx,(%esp)
  80252c:	e8 5e fc ff ff       	call   80218f <fstat>
  802531:	89 c6                	mov    %eax,%esi
	close(fd);
  802533:	89 1c 24             	mov    %ebx,(%esp)
  802536:	e8 91 ff ff ff       	call   8024cc <close>
  80253b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80253d:	89 d8                	mov    %ebx,%eax
  80253f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802542:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802545:	89 ec                	mov    %ebp,%esp
  802547:	5d                   	pop    %ebp
  802548:	c3                   	ret    

00802549 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  802549:	55                   	push   %ebp
  80254a:	89 e5                	mov    %esp,%ebp
  80254c:	53                   	push   %ebx
  80254d:	83 ec 14             	sub    $0x14,%esp
  802550:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  802555:	89 1c 24             	mov    %ebx,(%esp)
  802558:	e8 6f ff ff ff       	call   8024cc <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  80255d:	83 c3 01             	add    $0x1,%ebx
  802560:	83 fb 20             	cmp    $0x20,%ebx
  802563:	75 f0                	jne    802555 <close_all+0xc>
		close(i);
}
  802565:	83 c4 14             	add    $0x14,%esp
  802568:	5b                   	pop    %ebx
  802569:	5d                   	pop    %ebp
  80256a:	c3                   	ret    

0080256b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80256b:	55                   	push   %ebp
  80256c:	89 e5                	mov    %esp,%ebp
  80256e:	83 ec 58             	sub    $0x58,%esp
  802571:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802574:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802577:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80257a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  80257d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  802580:	89 44 24 04          	mov    %eax,0x4(%esp)
  802584:	8b 45 08             	mov    0x8(%ebp),%eax
  802587:	89 04 24             	mov    %eax,(%esp)
  80258a:	e8 1e fb ff ff       	call   8020ad <fd_lookup>
  80258f:	89 c3                	mov    %eax,%ebx
  802591:	85 c0                	test   %eax,%eax
  802593:	0f 88 e0 00 00 00    	js     802679 <dup+0x10e>
		return r;
	close(newfdnum);
  802599:	89 3c 24             	mov    %edi,(%esp)
  80259c:	e8 2b ff ff ff       	call   8024cc <close>

	newfd = INDEX2FD(newfdnum);
  8025a1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  8025a7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  8025aa:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8025ad:	89 04 24             	mov    %eax,(%esp)
  8025b0:	e8 6b fa ff ff       	call   802020 <fd2data>
  8025b5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8025b7:	89 34 24             	mov    %esi,(%esp)
  8025ba:	e8 61 fa ff ff       	call   802020 <fd2data>
  8025bf:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  8025c2:	89 da                	mov    %ebx,%edx
  8025c4:	89 d8                	mov    %ebx,%eax
  8025c6:	c1 e8 16             	shr    $0x16,%eax
  8025c9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8025d0:	a8 01                	test   $0x1,%al
  8025d2:	74 43                	je     802617 <dup+0xac>
  8025d4:	c1 ea 0c             	shr    $0xc,%edx
  8025d7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8025de:	a8 01                	test   $0x1,%al
  8025e0:	74 35                	je     802617 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  8025e2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8025e9:	25 07 0e 00 00       	and    $0xe07,%eax
  8025ee:	89 44 24 10          	mov    %eax,0x10(%esp)
  8025f2:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8025f5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8025f9:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  802600:	00 
  802601:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802605:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80260c:	e8 77 f4 ff ff       	call   801a88 <sys_page_map>
  802611:	89 c3                	mov    %eax,%ebx
  802613:	85 c0                	test   %eax,%eax
  802615:	78 3f                	js     802656 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  802617:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80261a:	89 c2                	mov    %eax,%edx
  80261c:	c1 ea 0c             	shr    $0xc,%edx
  80261f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  802626:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80262c:	89 54 24 10          	mov    %edx,0x10(%esp)
  802630:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802634:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80263b:	00 
  80263c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802640:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802647:	e8 3c f4 ff ff       	call   801a88 <sys_page_map>
  80264c:	89 c3                	mov    %eax,%ebx
  80264e:	85 c0                	test   %eax,%eax
  802650:	78 04                	js     802656 <dup+0xeb>
  802652:	89 fb                	mov    %edi,%ebx
  802654:	eb 23                	jmp    802679 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  802656:	89 74 24 04          	mov    %esi,0x4(%esp)
  80265a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802661:	e8 c4 f3 ff ff       	call   801a2a <sys_page_unmap>
	sys_page_unmap(0, nva);
  802666:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  802669:	89 44 24 04          	mov    %eax,0x4(%esp)
  80266d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802674:	e8 b1 f3 ff ff       	call   801a2a <sys_page_unmap>
	return r;
}
  802679:	89 d8                	mov    %ebx,%eax
  80267b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80267e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802681:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802684:	89 ec                	mov    %ebp,%esp
  802686:	5d                   	pop    %ebp
  802687:	c3                   	ret    

00802688 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  802688:	55                   	push   %ebp
  802689:	89 e5                	mov    %esp,%ebp
  80268b:	53                   	push   %ebx
  80268c:	83 ec 14             	sub    $0x14,%esp
  80268f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  802691:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  802697:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  80269e:	00 
  80269f:	c7 44 24 08 00 50 80 	movl   $0x805000,0x8(%esp)
  8026a6:	00 
  8026a7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026ab:	89 14 24             	mov    %edx,(%esp)
  8026ae:	e8 ad 13 00 00       	call   803a60 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8026b3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8026ba:	00 
  8026bb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8026bf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026c6:	e8 07 14 00 00       	call   803ad2 <ipc_recv>
}
  8026cb:	83 c4 14             	add    $0x14,%esp
  8026ce:	5b                   	pop    %ebx
  8026cf:	5d                   	pop    %ebp
  8026d0:	c3                   	ret    

008026d1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  8026d1:	55                   	push   %ebp
  8026d2:	89 e5                	mov    %esp,%ebp
  8026d4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  8026d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8026da:	8b 40 0c             	mov    0xc(%eax),%eax
  8026dd:	a3 00 50 80 00       	mov    %eax,0x805000
	fsipcbuf.set_size.req_size = newsize;
  8026e2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8026e5:	a3 04 50 80 00       	mov    %eax,0x805004
	return fsipc(FSREQ_SET_SIZE, NULL);
  8026ea:	ba 00 00 00 00       	mov    $0x0,%edx
  8026ef:	b8 02 00 00 00       	mov    $0x2,%eax
  8026f4:	e8 8f ff ff ff       	call   802688 <fsipc>
}
  8026f9:	c9                   	leave  
  8026fa:	c3                   	ret    

008026fb <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  8026fb:	55                   	push   %ebp
  8026fc:	89 e5                	mov    %esp,%ebp
  8026fe:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  802701:	8b 45 08             	mov    0x8(%ebp),%eax
  802704:	8b 40 0c             	mov    0xc(%eax),%eax
  802707:	a3 00 50 80 00       	mov    %eax,0x805000
	return fsipc(FSREQ_FLUSH, NULL);
  80270c:	ba 00 00 00 00       	mov    $0x0,%edx
  802711:	b8 06 00 00 00       	mov    $0x6,%eax
  802716:	e8 6d ff ff ff       	call   802688 <fsipc>
}
  80271b:	c9                   	leave  
  80271c:	c3                   	ret    

0080271d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80271d:	55                   	push   %ebp
  80271e:	89 e5                	mov    %esp,%ebp
  802720:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  802723:	ba 00 00 00 00       	mov    $0x0,%edx
  802728:	b8 08 00 00 00       	mov    $0x8,%eax
  80272d:	e8 56 ff ff ff       	call   802688 <fsipc>
}
  802732:	c9                   	leave  
  802733:	c3                   	ret    

00802734 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  802734:	55                   	push   %ebp
  802735:	89 e5                	mov    %esp,%ebp
  802737:	53                   	push   %ebx
  802738:	83 ec 14             	sub    $0x14,%esp
  80273b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80273e:	8b 45 08             	mov    0x8(%ebp),%eax
  802741:	8b 40 0c             	mov    0xc(%eax),%eax
  802744:	a3 00 50 80 00       	mov    %eax,0x805000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  802749:	ba 00 00 00 00       	mov    $0x0,%edx
  80274e:	b8 05 00 00 00       	mov    $0x5,%eax
  802753:	e8 30 ff ff ff       	call   802688 <fsipc>
  802758:	85 c0                	test   %eax,%eax
  80275a:	78 2b                	js     802787 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80275c:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  802763:	00 
  802764:	89 1c 24             	mov    %ebx,(%esp)
  802767:	e8 1e ec ff ff       	call   80138a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  80276c:	a1 80 50 80 00       	mov    0x805080,%eax
  802771:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  802777:	a1 84 50 80 00       	mov    0x805084,%eax
  80277c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  802782:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  802787:	83 c4 14             	add    $0x14,%esp
  80278a:	5b                   	pop    %ebx
  80278b:	5d                   	pop    %ebp
  80278c:	c3                   	ret    

0080278d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  80278d:	55                   	push   %ebp
  80278e:	89 e5                	mov    %esp,%ebp
  802790:	53                   	push   %ebx
  802791:	83 ec 14             	sub    $0x14,%esp
  802794:	8b 45 08             	mov    0x8(%ebp),%eax
  802797:	8b 55 0c             	mov    0xc(%ebp),%edx
  80279a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  80279d:	85 c0                	test   %eax,%eax
  80279f:	74 44                	je     8027e5 <devfile_write+0x58>
  8027a1:	85 d2                	test   %edx,%edx
  8027a3:	74 40                	je     8027e5 <devfile_write+0x58>
  8027a5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  8027ab:	77 38                	ja     8027e5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  8027ad:	8b 40 0c             	mov    0xc(%eax),%eax
  8027b0:	a3 00 50 80 00       	mov    %eax,0x805000
    fsipcbuf.write.req_n        = n;
  8027b5:	89 1d 04 50 80 00    	mov    %ebx,0x805004
    memmove(fsipcbuf.write.req_buf, buf, n);
  8027bb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8027bf:	89 54 24 04          	mov    %edx,0x4(%esp)
  8027c3:	c7 04 24 08 50 80 00 	movl   $0x805008,(%esp)
  8027ca:	e8 76 ed ff ff       	call   801545 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  8027cf:	ba 00 00 00 00       	mov    $0x0,%edx
  8027d4:	b8 04 00 00 00       	mov    $0x4,%eax
  8027d9:	e8 aa fe ff ff       	call   802688 <fsipc>
        return r;
    return n;
  8027de:	85 c0                	test   %eax,%eax
  8027e0:	0f 49 c3             	cmovns %ebx,%eax
  8027e3:	eb 05                	jmp    8027ea <devfile_write+0x5d>
  8027e5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8027ea:	83 c4 14             	add    $0x14,%esp
  8027ed:	5b                   	pop    %ebx
  8027ee:	5d                   	pop    %ebp
  8027ef:	c3                   	ret    

008027f0 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  8027f0:	55                   	push   %ebp
  8027f1:	89 e5                	mov    %esp,%ebp
  8027f3:	83 ec 18             	sub    $0x18,%esp
  8027f6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8027f9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8027fc:	8b 45 08             	mov    0x8(%ebp),%eax
  8027ff:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  802802:	85 c0                	test   %eax,%eax
  802804:	74 04                	je     80280a <devfile_read+0x1a>
  802806:	85 f6                	test   %esi,%esi
  802808:	75 07                	jne    802811 <devfile_read+0x21>
  80280a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  80280f:	eb 39                	jmp    80284a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  802811:	8b 40 0c             	mov    0xc(%eax),%eax
  802814:	a3 00 50 80 00       	mov    %eax,0x805000
  fsipcbuf.read.req_n         = n;
  802819:	8b 45 10             	mov    0x10(%ebp),%eax
  80281c:	a3 04 50 80 00       	mov    %eax,0x805004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  802821:	ba 00 00 00 00       	mov    $0x0,%edx
  802826:	b8 03 00 00 00       	mov    $0x3,%eax
  80282b:	e8 58 fe ff ff       	call   802688 <fsipc>
  802830:	89 c3                	mov    %eax,%ebx
  802832:	85 c0                	test   %eax,%eax
  802834:	78 14                	js     80284a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  802836:	89 44 24 08          	mov    %eax,0x8(%esp)
  80283a:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  802841:	00 
  802842:	89 34 24             	mov    %esi,(%esp)
  802845:	e8 fb ec ff ff       	call   801545 <memmove>
  return r;
}
  80284a:	89 d8                	mov    %ebx,%eax
  80284c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80284f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802852:	89 ec                	mov    %ebp,%esp
  802854:	5d                   	pop    %ebp
  802855:	c3                   	ret    

00802856 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  802856:	55                   	push   %ebp
  802857:	89 e5                	mov    %esp,%ebp
  802859:	53                   	push   %ebx
  80285a:	83 ec 14             	sub    $0x14,%esp
  80285d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  802860:	89 1c 24             	mov    %ebx,(%esp)
  802863:	e8 d8 ea ff ff       	call   801340 <strlen>
  802868:	89 c2                	mov    %eax,%edx
  80286a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  80286f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  802875:	7f 1f                	jg     802896 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  802877:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80287b:	c7 04 24 00 50 80 00 	movl   $0x805000,(%esp)
  802882:	e8 03 eb ff ff       	call   80138a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  802887:	ba 00 00 00 00       	mov    $0x0,%edx
  80288c:	b8 07 00 00 00       	mov    $0x7,%eax
  802891:	e8 f2 fd ff ff       	call   802688 <fsipc>
}
  802896:	83 c4 14             	add    $0x14,%esp
  802899:	5b                   	pop    %ebx
  80289a:	5d                   	pop    %ebp
  80289b:	c3                   	ret    

0080289c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  80289c:	55                   	push   %ebp
  80289d:	89 e5                	mov    %esp,%ebp
  80289f:	83 ec 28             	sub    $0x28,%esp
  8028a2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8028a5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8028a8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  8028ab:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  8028b0:	85 f6                	test   %esi,%esi
  8028b2:	74 65                	je     802919 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  8028b4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  8028bb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8028be:	89 04 24             	mov    %eax,(%esp)
  8028c1:	e8 75 f7 ff ff       	call   80203b <fd_alloc>
  8028c6:	89 c3                	mov    %eax,%ebx
  8028c8:	85 c0                	test   %eax,%eax
  8028ca:	78 4d                	js     802919 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  8028cc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8028d0:	c7 04 24 00 50 80 00 	movl   $0x805000,(%esp)
  8028d7:	e8 ae ea ff ff       	call   80138a <strcpy>
	fsipcbuf.open.req_omode = mode;
  8028dc:	8b 45 0c             	mov    0xc(%ebp),%eax
  8028df:	a3 00 54 80 00       	mov    %eax,0x805400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  8028e4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8028e7:	b8 01 00 00 00       	mov    $0x1,%eax
  8028ec:	e8 97 fd ff ff       	call   802688 <fsipc>
  8028f1:	89 c3                	mov    %eax,%ebx
  8028f3:	85 c0                	test   %eax,%eax
  8028f5:	79 15                	jns    80290c <open+0x70>
    fd_close(f, 0);
  8028f7:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8028fe:	00 
  8028ff:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802902:	89 04 24             	mov    %eax,(%esp)
  802905:	e8 3a fb ff ff       	call   802444 <fd_close>
    return r;
  80290a:	eb 0d                	jmp    802919 <open+0x7d>
  }
  return fd2num(f);
  80290c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80290f:	89 04 24             	mov    %eax,(%esp)
  802912:	e8 f9 f6 ff ff       	call   802010 <fd2num>
  802917:	89 c3                	mov    %eax,%ebx
}
  802919:	89 d8                	mov    %ebx,%eax
  80291b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80291e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802921:	89 ec                	mov    %ebp,%esp
  802923:	5d                   	pop    %ebp
  802924:	c3                   	ret    
  802925:	00 00                	add    %al,(%eax)
	...

00802928 <writebuf>:
};


static void
writebuf(struct printbuf *b)
{
  802928:	55                   	push   %ebp
  802929:	89 e5                	mov    %esp,%ebp
  80292b:	53                   	push   %ebx
  80292c:	83 ec 14             	sub    $0x14,%esp
  80292f:	89 c3                	mov    %eax,%ebx
	if (b->error > 0) {
  802931:	83 78 0c 00          	cmpl   $0x0,0xc(%eax)
  802935:	7e 31                	jle    802968 <writebuf+0x40>
		ssize_t result = write(b->fd, b->buf, b->idx);
  802937:	8b 40 04             	mov    0x4(%eax),%eax
  80293a:	89 44 24 08          	mov    %eax,0x8(%esp)
  80293e:	8d 43 10             	lea    0x10(%ebx),%eax
  802941:	89 44 24 04          	mov    %eax,0x4(%esp)
  802945:	8b 03                	mov    (%ebx),%eax
  802947:	89 04 24             	mov    %eax,(%esp)
  80294a:	e8 3b f9 ff ff       	call   80228a <write>
		if (result > 0)
  80294f:	85 c0                	test   %eax,%eax
  802951:	7e 03                	jle    802956 <writebuf+0x2e>
			b->result += result;
  802953:	01 43 08             	add    %eax,0x8(%ebx)
		if (result != b->idx) // error, or wrote less than supplied
  802956:	3b 43 04             	cmp    0x4(%ebx),%eax
  802959:	74 0d                	je     802968 <writebuf+0x40>
			b->error = (result < 0 ? result : 0);
  80295b:	85 c0                	test   %eax,%eax
  80295d:	ba 00 00 00 00       	mov    $0x0,%edx
  802962:	0f 4f c2             	cmovg  %edx,%eax
  802965:	89 43 0c             	mov    %eax,0xc(%ebx)
	}
}
  802968:	83 c4 14             	add    $0x14,%esp
  80296b:	5b                   	pop    %ebx
  80296c:	5d                   	pop    %ebp
  80296d:	c3                   	ret    

0080296e <vfprintf>:
	}
}

int
vfprintf(int fd, const char *fmt, va_list ap)
{
  80296e:	55                   	push   %ebp
  80296f:	89 e5                	mov    %esp,%ebp
  802971:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.fd = fd;
  802977:	8b 45 08             	mov    0x8(%ebp),%eax
  80297a:	89 85 e8 fe ff ff    	mov    %eax,-0x118(%ebp)
	b.idx = 0;
  802980:	c7 85 ec fe ff ff 00 	movl   $0x0,-0x114(%ebp)
  802987:	00 00 00 
	b.result = 0;
  80298a:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  802991:	00 00 00 
	b.error = 1;
  802994:	c7 85 f4 fe ff ff 01 	movl   $0x1,-0x10c(%ebp)
  80299b:	00 00 00 
	vprintfmt(putch, &b, fmt, ap);
  80299e:	8b 45 10             	mov    0x10(%ebp),%eax
  8029a1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8029a5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029a8:	89 44 24 08          	mov    %eax,0x8(%esp)
  8029ac:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  8029b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029b6:	c7 04 24 2a 2a 80 00 	movl   $0x802a2a,(%esp)
  8029bd:	e8 bb e3 ff ff       	call   800d7d <vprintfmt>
	if (b.idx > 0)
  8029c2:	83 bd ec fe ff ff 00 	cmpl   $0x0,-0x114(%ebp)
  8029c9:	7e 0b                	jle    8029d6 <vfprintf+0x68>
		writebuf(&b);
  8029cb:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  8029d1:	e8 52 ff ff ff       	call   802928 <writebuf>

	return (b.result ? b.result : b.error);
  8029d6:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8029dc:	85 c0                	test   %eax,%eax
  8029de:	0f 44 85 f4 fe ff ff 	cmove  -0x10c(%ebp),%eax
}
  8029e5:	c9                   	leave  
  8029e6:	c3                   	ret    

008029e7 <printf>:
	return cnt;
}

int
printf(const char *fmt, ...)
{
  8029e7:	55                   	push   %ebp
  8029e8:	89 e5                	mov    %esp,%ebp
  8029ea:	83 ec 18             	sub    $0x18,%esp

	return cnt;
}

int
printf(const char *fmt, ...)
  8029ed:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(1, fmt, ap);
  8029f0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8029f4:	8b 45 08             	mov    0x8(%ebp),%eax
  8029f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029fb:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  802a02:	e8 67 ff ff ff       	call   80296e <vfprintf>
	va_end(ap);

	return cnt;
}
  802a07:	c9                   	leave  
  802a08:	c3                   	ret    

00802a09 <fprintf>:
	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
{
  802a09:	55                   	push   %ebp
  802a0a:	89 e5                	mov    %esp,%ebp
  802a0c:	83 ec 18             	sub    $0x18,%esp

	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
  802a0f:	8d 45 10             	lea    0x10(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(fd, fmt, ap);
  802a12:	89 44 24 08          	mov    %eax,0x8(%esp)
  802a16:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a19:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a1d:	8b 45 08             	mov    0x8(%ebp),%eax
  802a20:	89 04 24             	mov    %eax,(%esp)
  802a23:	e8 46 ff ff ff       	call   80296e <vfprintf>
	va_end(ap);

	return cnt;
}
  802a28:	c9                   	leave  
  802a29:	c3                   	ret    

00802a2a <putch>:
	}
}

static void
putch(int ch, void *thunk)
{
  802a2a:	55                   	push   %ebp
  802a2b:	89 e5                	mov    %esp,%ebp
  802a2d:	53                   	push   %ebx
  802a2e:	83 ec 04             	sub    $0x4,%esp
	struct printbuf *b = (struct printbuf *) thunk;
  802a31:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  802a34:	8b 43 04             	mov    0x4(%ebx),%eax
  802a37:	8b 55 08             	mov    0x8(%ebp),%edx
  802a3a:	88 54 03 10          	mov    %dl,0x10(%ebx,%eax,1)
  802a3e:	83 c0 01             	add    $0x1,%eax
  802a41:	89 43 04             	mov    %eax,0x4(%ebx)
	if (b->idx == 256) {
  802a44:	3d 00 01 00 00       	cmp    $0x100,%eax
  802a49:	75 0e                	jne    802a59 <putch+0x2f>
		writebuf(b);
  802a4b:	89 d8                	mov    %ebx,%eax
  802a4d:	e8 d6 fe ff ff       	call   802928 <writebuf>
		b->idx = 0;
  802a52:	c7 43 04 00 00 00 00 	movl   $0x0,0x4(%ebx)
	}
}
  802a59:	83 c4 04             	add    $0x4,%esp
  802a5c:	5b                   	pop    %ebx
  802a5d:	5d                   	pop    %ebp
  802a5e:	c3                   	ret    
	...

00802a60 <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  802a60:	55                   	push   %ebp
  802a61:	89 e5                	mov    %esp,%ebp
  802a63:	57                   	push   %edi
  802a64:	56                   	push   %esi
  802a65:	53                   	push   %ebx
  802a66:	81 ec 9c 02 00 00    	sub    $0x29c,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  802a6c:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802a73:	00 
  802a74:	8b 45 08             	mov    0x8(%ebp),%eax
  802a77:	89 04 24             	mov    %eax,(%esp)
  802a7a:	e8 1d fe ff ff       	call   80289c <open>
  802a7f:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
  802a85:	89 c3                	mov    %eax,%ebx
  802a87:	85 c0                	test   %eax,%eax
  802a89:	0f 88 e0 05 00 00    	js     80306f <spawn+0x60f>
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
	    || elf->e_magic != ELF_MAGIC) {
  802a8f:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  802a96:	00 
  802a97:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  802a9d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802aa1:	89 1c 24             	mov    %ebx,(%esp)
  802aa4:	e8 6a f8 ff ff       	call   802313 <read>
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  802aa9:	3d 00 02 00 00       	cmp    $0x200,%eax
  802aae:	75 0c                	jne    802abc <spawn+0x5c>
	    || elf->e_magic != ELF_MAGIC) {
  802ab0:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  802ab7:	45 4c 46 
  802aba:	74 36                	je     802af2 <spawn+0x92>
		close(fd);
  802abc:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  802ac2:	89 04 24             	mov    %eax,(%esp)
  802ac5:	e8 02 fa ff ff       	call   8024cc <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  802aca:	c7 44 24 08 7f 45 4c 	movl   $0x464c457f,0x8(%esp)
  802ad1:	46 
  802ad2:	8b 85 e8 fd ff ff    	mov    -0x218(%ebp),%eax
  802ad8:	89 44 24 04          	mov    %eax,0x4(%esp)
  802adc:	c7 04 24 b8 45 80 00 	movl   $0x8045b8,(%esp)
  802ae3:	e8 dd e0 ff ff       	call   800bc5 <cprintf>
  802ae8:	bb f2 ff ff ff       	mov    $0xfffffff2,%ebx
		return -E_NOT_EXEC;
  802aed:	e9 7d 05 00 00       	jmp    80306f <spawn+0x60f>
  802af2:	ba 07 00 00 00       	mov    $0x7,%edx
  802af7:	89 d0                	mov    %edx,%eax
  802af9:	cd 30                	int    $0x30
  802afb:	89 85 84 fd ff ff    	mov    %eax,-0x27c(%ebp)
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  802b01:	85 c0                	test   %eax,%eax
  802b03:	0f 88 60 05 00 00    	js     803069 <spawn+0x609>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  802b09:	89 c6                	mov    %eax,%esi
  802b0b:	81 e6 ff 03 00 00    	and    $0x3ff,%esi
  802b11:	6b f6 7c             	imul   $0x7c,%esi,%esi
  802b14:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  802b1a:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  802b20:	b9 11 00 00 00       	mov    $0x11,%ecx
  802b25:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  802b27:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  802b2d:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  802b33:	8b 55 0c             	mov    0xc(%ebp),%edx
  802b36:	8b 02                	mov    (%edx),%eax
  802b38:	bb 00 00 00 00       	mov    $0x0,%ebx
  802b3d:	be 00 00 00 00       	mov    $0x0,%esi
  802b42:	85 c0                	test   %eax,%eax
  802b44:	75 16                	jne    802b5c <spawn+0xfc>
  802b46:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  802b4d:	00 00 00 
  802b50:	c7 85 78 fd ff ff 00 	movl   $0x0,-0x288(%ebp)
  802b57:	00 00 00 
  802b5a:	eb 2c                	jmp    802b88 <spawn+0x128>
  802b5c:	8b 7d 0c             	mov    0xc(%ebp),%edi
		string_size += strlen(argv[argc]) + 1;
  802b5f:	89 04 24             	mov    %eax,(%esp)
  802b62:	e8 d9 e7 ff ff       	call   801340 <strlen>
  802b67:	8d 5c 18 01          	lea    0x1(%eax,%ebx,1),%ebx
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  802b6b:	83 c6 01             	add    $0x1,%esi
  802b6e:	8d 14 b5 00 00 00 00 	lea    0x0(,%esi,4),%edx
  802b75:	8b 04 b7             	mov    (%edi,%esi,4),%eax
  802b78:	85 c0                	test   %eax,%eax
  802b7a:	75 e3                	jne    802b5f <spawn+0xff>
  802b7c:	89 95 7c fd ff ff    	mov    %edx,-0x284(%ebp)
  802b82:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  802b88:	f7 db                	neg    %ebx
  802b8a:	8d bb 00 10 40 00    	lea    0x401000(%ebx),%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  802b90:	89 fa                	mov    %edi,%edx
  802b92:	83 e2 fc             	and    $0xfffffffc,%edx
  802b95:	89 f0                	mov    %esi,%eax
  802b97:	f7 d0                	not    %eax
  802b99:	8d 04 82             	lea    (%edx,%eax,4),%eax
  802b9c:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  802ba2:	83 e8 08             	sub    $0x8,%eax
  802ba5:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
	return child;

error:
	sys_env_destroy(child);
	close(fd);
	return r;
  802bab:	bb fc ff ff ff       	mov    $0xfffffffc,%ebx
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  802bb0:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  802bb5:	0f 86 b4 04 00 00    	jbe    80306f <spawn+0x60f>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  802bbb:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802bc2:	00 
  802bc3:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802bca:	00 
  802bcb:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802bd2:	e8 0f ef ff ff       	call   801ae6 <sys_page_alloc>
  802bd7:	89 c3                	mov    %eax,%ebx
  802bd9:	85 c0                	test   %eax,%eax
  802bdb:	0f 88 8e 04 00 00    	js     80306f <spawn+0x60f>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  802be1:	85 f6                	test   %esi,%esi
  802be3:	7e 46                	jle    802c2b <spawn+0x1cb>
  802be5:	bb 00 00 00 00       	mov    $0x0,%ebx
  802bea:	89 b5 8c fd ff ff    	mov    %esi,-0x274(%ebp)
  802bf0:	8b 75 0c             	mov    0xc(%ebp),%esi
		argv_store[i] = UTEMP2USTACK(string_store);
  802bf3:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  802bf9:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802bff:	89 04 9a             	mov    %eax,(%edx,%ebx,4)
		strcpy(string_store, argv[i]);
  802c02:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  802c05:	89 44 24 04          	mov    %eax,0x4(%esp)
  802c09:	89 3c 24             	mov    %edi,(%esp)
  802c0c:	e8 79 e7 ff ff       	call   80138a <strcpy>
		string_store += strlen(argv[i]) + 1;
  802c11:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  802c14:	89 04 24             	mov    %eax,(%esp)
  802c17:	e8 24 e7 ff ff       	call   801340 <strlen>
  802c1c:	8d 7c 38 01          	lea    0x1(%eax,%edi,1),%edi
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  802c20:	83 c3 01             	add    $0x1,%ebx
  802c23:	3b 9d 8c fd ff ff    	cmp    -0x274(%ebp),%ebx
  802c29:	7c c8                	jl     802bf3 <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
		strcpy(string_store, argv[i]);
		string_store += strlen(argv[i]) + 1;
	}
	argv_store[argc] = 0;
  802c2b:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802c31:	8b 85 7c fd ff ff    	mov    -0x284(%ebp),%eax
  802c37:	c7 04 02 00 00 00 00 	movl   $0x0,(%edx,%eax,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  802c3e:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  802c44:	74 24                	je     802c6a <spawn+0x20a>
  802c46:	c7 44 24 0c 44 46 80 	movl   $0x804644,0xc(%esp)
  802c4d:	00 
  802c4e:	c7 44 24 08 a1 3f 80 	movl   $0x803fa1,0x8(%esp)
  802c55:	00 
  802c56:	c7 44 24 04 d9 00 00 	movl   $0xd9,0x4(%esp)
  802c5d:	00 
  802c5e:	c7 04 24 d2 45 80 00 	movl   $0x8045d2,(%esp)
  802c65:	e8 96 de ff ff       	call   800b00 <_panic>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  802c6a:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  802c70:	2d 00 30 80 11       	sub    $0x11803000,%eax
  802c75:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802c7b:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  802c7e:	8b 95 78 fd ff ff    	mov    -0x288(%ebp),%edx
  802c84:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  802c8a:	89 10                	mov    %edx,(%eax)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  802c8c:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  802c92:	2d 08 30 80 11       	sub    $0x11803008,%eax
  802c97:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  802c9d:	c7 44 24 10 07 00 00 	movl   $0x7,0x10(%esp)
  802ca4:	00 
  802ca5:	c7 44 24 0c 00 d0 bf 	movl   $0xeebfd000,0xc(%esp)
  802cac:	ee 
  802cad:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802cb3:	89 44 24 08          	mov    %eax,0x8(%esp)
  802cb7:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802cbe:	00 
  802cbf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802cc6:	e8 bd ed ff ff       	call   801a88 <sys_page_map>
  802ccb:	89 c3                	mov    %eax,%ebx
  802ccd:	85 c0                	test   %eax,%eax
  802ccf:	78 1a                	js     802ceb <spawn+0x28b>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  802cd1:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802cd8:	00 
  802cd9:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802ce0:	e8 45 ed ff ff       	call   801a2a <sys_page_unmap>
  802ce5:	89 c3                	mov    %eax,%ebx
  802ce7:	85 c0                	test   %eax,%eax
  802ce9:	79 19                	jns    802d04 <spawn+0x2a4>
		goto error;

	return 0;

error:
	sys_page_unmap(0, UTEMP);
  802ceb:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802cf2:	00 
  802cf3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802cfa:	e8 2b ed ff ff       	call   801a2a <sys_page_unmap>
  802cff:	e9 6b 03 00 00       	jmp    80306f <spawn+0x60f>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  802d04:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  802d0a:	66 83 bd 14 fe ff ff 	cmpw   $0x0,-0x1ec(%ebp)
  802d11:	00 
  802d12:	0f 84 e4 01 00 00    	je     802efc <spawn+0x49c>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  802d18:	8d 84 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%eax
  802d1f:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
  802d25:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  802d2c:	00 00 00 
	for (i = 0; i < elf->e_phnum; i++, ph++) {
		if (ph->p_type != ELF_PROG_LOAD)
  802d2f:	8b 95 80 fd ff ff    	mov    -0x280(%ebp),%edx
  802d35:	83 3a 01             	cmpl   $0x1,(%edx)
  802d38:	0f 85 9c 01 00 00    	jne    802eda <spawn+0x47a>
			continue;
		perm = PTE_P | PTE_U;
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  802d3e:	8b 42 18             	mov    0x18(%edx),%eax
  802d41:	83 e0 02             	and    $0x2,%eax
  802d44:	83 f8 01             	cmp    $0x1,%eax
  802d47:	19 c0                	sbb    %eax,%eax
  802d49:	83 e0 fe             	and    $0xfffffffe,%eax
  802d4c:	83 c0 07             	add    $0x7,%eax
  802d4f:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
  802d55:	8b 52 04             	mov    0x4(%edx),%edx
  802d58:	89 95 78 fd ff ff    	mov    %edx,-0x288(%ebp)
  802d5e:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  802d64:	8b 58 10             	mov    0x10(%eax),%ebx
  802d67:	8b 50 14             	mov    0x14(%eax),%edx
  802d6a:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
  802d70:	8b 40 08             	mov    0x8(%eax),%eax
  802d73:	89 85 90 fd ff ff    	mov    %eax,-0x270(%ebp)
	int i, r;
	void *blk;

	//cprintf("map_segment %x+%x\n", va, memsz);

	if ((i = PGOFF(va))) {
  802d79:	25 ff 0f 00 00       	and    $0xfff,%eax
  802d7e:	74 16                	je     802d96 <spawn+0x336>
		va -= i;
  802d80:	29 85 90 fd ff ff    	sub    %eax,-0x270(%ebp)
		memsz += i;
  802d86:	01 c2                	add    %eax,%edx
  802d88:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
		filesz += i;
  802d8e:	01 c3                	add    %eax,%ebx
		fileoffset -= i;
  802d90:	29 85 78 fd ff ff    	sub    %eax,-0x288(%ebp)
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  802d96:	83 bd 8c fd ff ff 00 	cmpl   $0x0,-0x274(%ebp)
  802d9d:	0f 84 37 01 00 00    	je     802eda <spawn+0x47a>
  802da3:	bf 00 00 00 00       	mov    $0x0,%edi
  802da8:	be 00 00 00 00       	mov    $0x0,%esi
		if (i >= filesz) {
  802dad:	39 fb                	cmp    %edi,%ebx
  802daf:	77 31                	ja     802de2 <spawn+0x382>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  802db1:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802db7:	89 54 24 08          	mov    %edx,0x8(%esp)
  802dbb:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  802dc1:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802dc5:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802dcb:	89 04 24             	mov    %eax,(%esp)
  802dce:	e8 13 ed ff ff       	call   801ae6 <sys_page_alloc>
  802dd3:	85 c0                	test   %eax,%eax
  802dd5:	0f 89 eb 00 00 00    	jns    802ec6 <spawn+0x466>
  802ddb:	89 c3                	mov    %eax,%ebx
  802ddd:	e9 69 02 00 00       	jmp    80304b <spawn+0x5eb>
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  802de2:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802de9:	00 
  802dea:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802df1:	00 
  802df2:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802df9:	e8 e8 ec ff ff       	call   801ae6 <sys_page_alloc>
  802dfe:	85 c0                	test   %eax,%eax
  802e00:	0f 88 3b 02 00 00    	js     803041 <spawn+0x5e1>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  802e06:	8b 85 78 fd ff ff    	mov    -0x288(%ebp),%eax
  802e0c:	8d 04 06             	lea    (%esi,%eax,1),%eax
  802e0f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802e13:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802e19:	89 14 24             	mov    %edx,(%esp)
  802e1c:	e8 d4 f2 ff ff       	call   8020f5 <seek>
  802e21:	85 c0                	test   %eax,%eax
  802e23:	0f 88 1c 02 00 00    	js     803045 <spawn+0x5e5>
				return r;
			if ((r = read(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  802e29:	89 d8                	mov    %ebx,%eax
  802e2b:	29 f8                	sub    %edi,%eax
  802e2d:	3d 00 10 00 00       	cmp    $0x1000,%eax
  802e32:	ba 00 10 00 00       	mov    $0x1000,%edx
  802e37:	0f 47 c2             	cmova  %edx,%eax
  802e3a:	89 44 24 08          	mov    %eax,0x8(%esp)
  802e3e:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802e45:	00 
  802e46:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  802e4c:	89 04 24             	mov    %eax,(%esp)
  802e4f:	e8 bf f4 ff ff       	call   802313 <read>
  802e54:	85 c0                	test   %eax,%eax
  802e56:	0f 88 ed 01 00 00    	js     803049 <spawn+0x5e9>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  802e5c:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802e62:	89 54 24 10          	mov    %edx,0x10(%esp)
  802e66:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  802e6c:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  802e70:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802e76:	89 44 24 08          	mov    %eax,0x8(%esp)
  802e7a:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802e81:	00 
  802e82:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802e89:	e8 fa eb ff ff       	call   801a88 <sys_page_map>
  802e8e:	85 c0                	test   %eax,%eax
  802e90:	79 20                	jns    802eb2 <spawn+0x452>
				panic("spawn: sys_page_map data: %e", r);
  802e92:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802e96:	c7 44 24 08 de 45 80 	movl   $0x8045de,0x8(%esp)
  802e9d:	00 
  802e9e:	c7 44 24 04 0c 01 00 	movl   $0x10c,0x4(%esp)
  802ea5:	00 
  802ea6:	c7 04 24 d2 45 80 00 	movl   $0x8045d2,(%esp)
  802ead:	e8 4e dc ff ff       	call   800b00 <_panic>
			sys_page_unmap(0, UTEMP);
  802eb2:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802eb9:	00 
  802eba:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802ec1:	e8 64 eb ff ff       	call   801a2a <sys_page_unmap>
		memsz += i;
		filesz += i;
		fileoffset -= i;
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  802ec6:	81 c6 00 10 00 00    	add    $0x1000,%esi
  802ecc:	89 f7                	mov    %esi,%edi
  802ece:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  802ed4:	0f 87 d3 fe ff ff    	ja     802dad <spawn+0x34d>
	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  802eda:	83 85 7c fd ff ff 01 	addl   $0x1,-0x284(%ebp)
  802ee1:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  802ee8:	3b 85 7c fd ff ff    	cmp    -0x284(%ebp),%eax
  802eee:	7e 0c                	jle    802efc <spawn+0x49c>
  802ef0:	83 85 80 fd ff ff 20 	addl   $0x20,-0x280(%ebp)
  802ef7:	e9 33 fe ff ff       	jmp    802d2f <spawn+0x2cf>
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
				     fd, ph->p_filesz, ph->p_offset, perm)) < 0)
			goto error;
	}
	close(fd);
  802efc:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802f02:	89 14 24             	mov    %edx,(%esp)
  802f05:	e8 c2 f5 ff ff       	call   8024cc <close>
static int
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
  802f0a:	e8 6a ec ff ff       	call   801b79 <sys_getenvid>
  802f0f:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  802f15:	b8 00 00 00 00       	mov    $0x0,%eax
  802f1a:	bb 00 00 00 00       	mov    $0x0,%ebx
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
        if (((vpd[PDX(va)] & PTE_P) && (vpt[VPN(va)] & PTE_P) && (vpt[VPN(va)] & PTE_SHARE))) {
  802f1f:	be 00 d0 7b ef       	mov    $0xef7bd000,%esi
  802f24:	bf 00 00 40 ef       	mov    $0xef400000,%edi
  802f29:	89 c2                	mov    %eax,%edx
  802f2b:	89 d1                	mov    %edx,%ecx
  802f2d:	c1 e9 16             	shr    $0x16,%ecx
  802f30:	8b 0c 8e             	mov    (%esi,%ecx,4),%ecx
  802f33:	f6 c1 01             	test   $0x1,%cl
  802f36:	74 5f                	je     802f97 <spawn+0x537>
  802f38:	c1 ea 0c             	shr    $0xc,%edx
  802f3b:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  802f3e:	f6 c1 01             	test   $0x1,%cl
  802f41:	74 54                	je     802f97 <spawn+0x537>
  802f43:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  802f46:	f6 c5 04             	test   $0x4,%ch
  802f49:	74 4c                	je     802f97 <spawn+0x537>
            if((r=sys_page_map(cur, (void *)(va), child, (void *)(va), vpt[VPN(va)]&PTE_USER))<0)
  802f4b:	8b 04 97             	mov    (%edi,%edx,4),%eax
  802f4e:	25 07 0e 00 00       	and    $0xe07,%eax
  802f53:	89 44 24 10          	mov    %eax,0x10(%esp)
  802f57:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  802f5b:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802f61:	89 44 24 08          	mov    %eax,0x8(%esp)
  802f65:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802f69:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802f6f:	89 14 24             	mov    %edx,(%esp)
  802f72:	e8 11 eb ff ff       	call   801a88 <sys_page_map>
  802f77:	85 c0                	test   %eax,%eax
  802f79:	79 1c                	jns    802f97 <spawn+0x537>
                panic("copy_shared_pages: error sharing\n");
  802f7b:	c7 44 24 08 6c 46 80 	movl   $0x80466c,0x8(%esp)
  802f82:	00 
  802f83:	c7 44 24 04 1d 01 00 	movl   $0x11d,0x4(%esp)
  802f8a:	00 
  802f8b:	c7 04 24 d2 45 80 00 	movl   $0x8045d2,(%esp)
  802f92:	e8 69 db ff ff       	call   800b00 <_panic>
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
  802f97:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  802f9d:	89 da                	mov    %ebx,%edx
  802f9f:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  802fa5:	75 84                	jne    802f2b <spawn+0x4cb>
	}
	close(fd);
	fd = -1;

	// Copy shared library state.
	if ((r = copy_shared_pages(child)) < 0)
  802fa7:	85 c0                	test   %eax,%eax
  802fa9:	79 20                	jns    802fcb <spawn+0x56b>
		panic("copy_shared_pages: %e", r);
  802fab:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802faf:	c7 44 24 08 fb 45 80 	movl   $0x8045fb,0x8(%esp)
  802fb6:	00 
  802fb7:	c7 44 24 04 82 00 00 	movl   $0x82,0x4(%esp)
  802fbe:	00 
  802fbf:	c7 04 24 d2 45 80 00 	movl   $0x8045d2,(%esp)
  802fc6:	e8 35 db ff ff       	call   800b00 <_panic>

	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  802fcb:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  802fd1:	89 44 24 04          	mov    %eax,0x4(%esp)
  802fd5:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802fdb:	89 04 24             	mov    %eax,(%esp)
  802fde:	e8 8b e9 ff ff       	call   80196e <sys_env_set_trapframe>
  802fe3:	85 c0                	test   %eax,%eax
  802fe5:	79 20                	jns    803007 <spawn+0x5a7>
		panic("sys_env_set_trapframe: %e", r);
  802fe7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802feb:	c7 44 24 08 11 46 80 	movl   $0x804611,0x8(%esp)
  802ff2:	00 
  802ff3:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  802ffa:	00 
  802ffb:	c7 04 24 d2 45 80 00 	movl   $0x8045d2,(%esp)
  803002:	e8 f9 da ff ff       	call   800b00 <_panic>

	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  803007:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  80300e:	00 
  80300f:	8b 95 84 fd ff ff    	mov    -0x27c(%ebp),%edx
  803015:	89 14 24             	mov    %edx,(%esp)
  803018:	e8 af e9 ff ff       	call   8019cc <sys_env_set_status>
  80301d:	85 c0                	test   %eax,%eax
  80301f:	79 48                	jns    803069 <spawn+0x609>
		panic("sys_env_set_status: %e", r);
  803021:	89 44 24 0c          	mov    %eax,0xc(%esp)
  803025:	c7 44 24 08 2b 46 80 	movl   $0x80462b,0x8(%esp)
  80302c:	00 
  80302d:	c7 44 24 04 88 00 00 	movl   $0x88,0x4(%esp)
  803034:	00 
  803035:	c7 04 24 d2 45 80 00 	movl   $0x8045d2,(%esp)
  80303c:	e8 bf da ff ff       	call   800b00 <_panic>
  803041:	89 c3                	mov    %eax,%ebx
  803043:	eb 06                	jmp    80304b <spawn+0x5eb>
  803045:	89 c3                	mov    %eax,%ebx
  803047:	eb 02                	jmp    80304b <spawn+0x5eb>
  803049:	89 c3                	mov    %eax,%ebx

	return child;

error:
	sys_env_destroy(child);
  80304b:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  803051:	89 04 24             	mov    %eax,(%esp)
  803054:	e8 54 eb ff ff       	call   801bad <sys_env_destroy>
	close(fd);
  803059:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  80305f:	89 14 24             	mov    %edx,(%esp)
  803062:	e8 65 f4 ff ff       	call   8024cc <close>
	return r;
  803067:	eb 06                	jmp    80306f <spawn+0x60f>
  803069:	8b 9d 84 fd ff ff    	mov    -0x27c(%ebp),%ebx
}
  80306f:	89 d8                	mov    %ebx,%eax
  803071:	81 c4 9c 02 00 00    	add    $0x29c,%esp
  803077:	5b                   	pop    %ebx
  803078:	5e                   	pop    %esi
  803079:	5f                   	pop    %edi
  80307a:	5d                   	pop    %ebp
  80307b:	c3                   	ret    

0080307c <spawnl>:

// Spawn, taking command-line arguments array directly on the stack.
int
spawnl(const char *prog, const char *arg0, ...)
{
  80307c:	55                   	push   %ebp
  80307d:	89 e5                	mov    %esp,%ebp
  80307f:	83 ec 18             	sub    $0x18,%esp
	return spawn(prog, &arg0);
  803082:	8d 45 0c             	lea    0xc(%ebp),%eax
  803085:	89 44 24 04          	mov    %eax,0x4(%esp)
  803089:	8b 45 08             	mov    0x8(%ebp),%eax
  80308c:	89 04 24             	mov    %eax,(%esp)
  80308f:	e8 cc f9 ff ff       	call   802a60 <spawn>
}
  803094:	c9                   	leave  
  803095:	c3                   	ret    
	...

008030a0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  8030a0:	55                   	push   %ebp
  8030a1:	89 e5                	mov    %esp,%ebp
  8030a3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  8030a6:	c7 44 24 04 8e 46 80 	movl   $0x80468e,0x4(%esp)
  8030ad:	00 
  8030ae:	8b 45 0c             	mov    0xc(%ebp),%eax
  8030b1:	89 04 24             	mov    %eax,(%esp)
  8030b4:	e8 d1 e2 ff ff       	call   80138a <strcpy>
	return 0;
}
  8030b9:	b8 00 00 00 00       	mov    $0x0,%eax
  8030be:	c9                   	leave  
  8030bf:	c3                   	ret    

008030c0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8030c0:	55                   	push   %ebp
  8030c1:	89 e5                	mov    %esp,%ebp
  8030c3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8030c6:	8b 45 08             	mov    0x8(%ebp),%eax
  8030c9:	8b 40 0c             	mov    0xc(%eax),%eax
  8030cc:	89 04 24             	mov    %eax,(%esp)
  8030cf:	e8 9d 02 00 00       	call   803371 <nsipc_close>
}
  8030d4:	c9                   	leave  
  8030d5:	c3                   	ret    

008030d6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8030d6:	55                   	push   %ebp
  8030d7:	89 e5                	mov    %esp,%ebp
  8030d9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8030dc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8030e3:	00 
  8030e4:	8b 45 10             	mov    0x10(%ebp),%eax
  8030e7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8030eb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8030ee:	89 44 24 04          	mov    %eax,0x4(%esp)
  8030f2:	8b 45 08             	mov    0x8(%ebp),%eax
  8030f5:	8b 40 0c             	mov    0xc(%eax),%eax
  8030f8:	89 04 24             	mov    %eax,(%esp)
  8030fb:	e8 ad 02 00 00       	call   8033ad <nsipc_send>
}
  803100:	c9                   	leave  
  803101:	c3                   	ret    

00803102 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  803102:	55                   	push   %ebp
  803103:	89 e5                	mov    %esp,%ebp
  803105:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  803108:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80310f:	00 
  803110:	8b 45 10             	mov    0x10(%ebp),%eax
  803113:	89 44 24 08          	mov    %eax,0x8(%esp)
  803117:	8b 45 0c             	mov    0xc(%ebp),%eax
  80311a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80311e:	8b 45 08             	mov    0x8(%ebp),%eax
  803121:	8b 40 0c             	mov    0xc(%eax),%eax
  803124:	89 04 24             	mov    %eax,(%esp)
  803127:	e8 f4 02 00 00       	call   803420 <nsipc_recv>
}
  80312c:	c9                   	leave  
  80312d:	c3                   	ret    

0080312e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80312e:	55                   	push   %ebp
  80312f:	89 e5                	mov    %esp,%ebp
  803131:	56                   	push   %esi
  803132:	53                   	push   %ebx
  803133:	83 ec 20             	sub    $0x20,%esp
  803136:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  803138:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80313b:	89 04 24             	mov    %eax,(%esp)
  80313e:	e8 f8 ee ff ff       	call   80203b <fd_alloc>
  803143:	89 c3                	mov    %eax,%ebx
  803145:	85 c0                	test   %eax,%eax
  803147:	78 21                	js     80316a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  803149:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  803150:	00 
  803151:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803154:	89 44 24 04          	mov    %eax,0x4(%esp)
  803158:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80315f:	e8 82 e9 ff ff       	call   801ae6 <sys_page_alloc>
  803164:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  803166:	85 c0                	test   %eax,%eax
  803168:	79 0a                	jns    803174 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80316a:	89 34 24             	mov    %esi,(%esp)
  80316d:	e8 ff 01 00 00       	call   803371 <nsipc_close>
		return r;
  803172:	eb 28                	jmp    80319c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  803174:	8b 15 3c 80 80 00    	mov    0x80803c,%edx
  80317a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80317d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80317f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803182:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  803189:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80318c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80318f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803192:	89 04 24             	mov    %eax,(%esp)
  803195:	e8 76 ee ff ff       	call   802010 <fd2num>
  80319a:	89 c3                	mov    %eax,%ebx
}
  80319c:	89 d8                	mov    %ebx,%eax
  80319e:	83 c4 20             	add    $0x20,%esp
  8031a1:	5b                   	pop    %ebx
  8031a2:	5e                   	pop    %esi
  8031a3:	5d                   	pop    %ebp
  8031a4:	c3                   	ret    

008031a5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  8031a5:	55                   	push   %ebp
  8031a6:	89 e5                	mov    %esp,%ebp
  8031a8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  8031ab:	8b 45 10             	mov    0x10(%ebp),%eax
  8031ae:	89 44 24 08          	mov    %eax,0x8(%esp)
  8031b2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8031b5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8031b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8031bc:	89 04 24             	mov    %eax,(%esp)
  8031bf:	e8 61 01 00 00       	call   803325 <nsipc_socket>
  8031c4:	85 c0                	test   %eax,%eax
  8031c6:	78 05                	js     8031cd <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8031c8:	e8 61 ff ff ff       	call   80312e <alloc_sockfd>
}
  8031cd:	c9                   	leave  
  8031ce:	66 90                	xchg   %ax,%ax
  8031d0:	c3                   	ret    

008031d1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8031d1:	55                   	push   %ebp
  8031d2:	89 e5                	mov    %esp,%ebp
  8031d4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8031d7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8031da:	89 54 24 04          	mov    %edx,0x4(%esp)
  8031de:	89 04 24             	mov    %eax,(%esp)
  8031e1:	e8 c7 ee ff ff       	call   8020ad <fd_lookup>
  8031e6:	85 c0                	test   %eax,%eax
  8031e8:	78 15                	js     8031ff <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  8031ea:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8031ed:	8b 0a                	mov    (%edx),%ecx
  8031ef:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8031f4:	3b 0d 3c 80 80 00    	cmp    0x80803c,%ecx
  8031fa:	75 03                	jne    8031ff <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  8031fc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  8031ff:	c9                   	leave  
  803200:	c3                   	ret    

00803201 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  803201:	55                   	push   %ebp
  803202:	89 e5                	mov    %esp,%ebp
  803204:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803207:	8b 45 08             	mov    0x8(%ebp),%eax
  80320a:	e8 c2 ff ff ff       	call   8031d1 <fd2sockid>
  80320f:	85 c0                	test   %eax,%eax
  803211:	78 0f                	js     803222 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  803213:	8b 55 0c             	mov    0xc(%ebp),%edx
  803216:	89 54 24 04          	mov    %edx,0x4(%esp)
  80321a:	89 04 24             	mov    %eax,(%esp)
  80321d:	e8 2d 01 00 00       	call   80334f <nsipc_listen>
}
  803222:	c9                   	leave  
  803223:	c3                   	ret    

00803224 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  803224:	55                   	push   %ebp
  803225:	89 e5                	mov    %esp,%ebp
  803227:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80322a:	8b 45 08             	mov    0x8(%ebp),%eax
  80322d:	e8 9f ff ff ff       	call   8031d1 <fd2sockid>
  803232:	85 c0                	test   %eax,%eax
  803234:	78 16                	js     80324c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  803236:	8b 55 10             	mov    0x10(%ebp),%edx
  803239:	89 54 24 08          	mov    %edx,0x8(%esp)
  80323d:	8b 55 0c             	mov    0xc(%ebp),%edx
  803240:	89 54 24 04          	mov    %edx,0x4(%esp)
  803244:	89 04 24             	mov    %eax,(%esp)
  803247:	e8 54 02 00 00       	call   8034a0 <nsipc_connect>
}
  80324c:	c9                   	leave  
  80324d:	c3                   	ret    

0080324e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80324e:	55                   	push   %ebp
  80324f:	89 e5                	mov    %esp,%ebp
  803251:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803254:	8b 45 08             	mov    0x8(%ebp),%eax
  803257:	e8 75 ff ff ff       	call   8031d1 <fd2sockid>
  80325c:	85 c0                	test   %eax,%eax
  80325e:	78 0f                	js     80326f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  803260:	8b 55 0c             	mov    0xc(%ebp),%edx
  803263:	89 54 24 04          	mov    %edx,0x4(%esp)
  803267:	89 04 24             	mov    %eax,(%esp)
  80326a:	e8 1c 01 00 00       	call   80338b <nsipc_shutdown>
}
  80326f:	c9                   	leave  
  803270:	c3                   	ret    

00803271 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  803271:	55                   	push   %ebp
  803272:	89 e5                	mov    %esp,%ebp
  803274:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  803277:	8b 45 08             	mov    0x8(%ebp),%eax
  80327a:	e8 52 ff ff ff       	call   8031d1 <fd2sockid>
  80327f:	85 c0                	test   %eax,%eax
  803281:	78 16                	js     803299 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  803283:	8b 55 10             	mov    0x10(%ebp),%edx
  803286:	89 54 24 08          	mov    %edx,0x8(%esp)
  80328a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80328d:	89 54 24 04          	mov    %edx,0x4(%esp)
  803291:	89 04 24             	mov    %eax,(%esp)
  803294:	e8 46 02 00 00       	call   8034df <nsipc_bind>
}
  803299:	c9                   	leave  
  80329a:	c3                   	ret    

0080329b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80329b:	55                   	push   %ebp
  80329c:	89 e5                	mov    %esp,%ebp
  80329e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8032a1:	8b 45 08             	mov    0x8(%ebp),%eax
  8032a4:	e8 28 ff ff ff       	call   8031d1 <fd2sockid>
  8032a9:	85 c0                	test   %eax,%eax
  8032ab:	78 1f                	js     8032cc <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  8032ad:	8b 55 10             	mov    0x10(%ebp),%edx
  8032b0:	89 54 24 08          	mov    %edx,0x8(%esp)
  8032b4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8032b7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8032bb:	89 04 24             	mov    %eax,(%esp)
  8032be:	e8 5b 02 00 00       	call   80351e <nsipc_accept>
  8032c3:	85 c0                	test   %eax,%eax
  8032c5:	78 05                	js     8032cc <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8032c7:	e8 62 fe ff ff       	call   80312e <alloc_sockfd>
}
  8032cc:	c9                   	leave  
  8032cd:	8d 76 00             	lea    0x0(%esi),%esi
  8032d0:	c3                   	ret    
	...

008032e0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8032e0:	55                   	push   %ebp
  8032e1:	89 e5                	mov    %esp,%ebp
  8032e3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8032e6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8032ec:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8032f3:	00 
  8032f4:	c7 44 24 08 00 70 80 	movl   $0x807000,0x8(%esp)
  8032fb:	00 
  8032fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  803300:	89 14 24             	mov    %edx,(%esp)
  803303:	e8 58 07 00 00       	call   803a60 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  803308:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80330f:	00 
  803310:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  803317:	00 
  803318:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80331b:	89 04 24             	mov    %eax,(%esp)
  80331e:	e8 af 07 00 00       	call   803ad2 <ipc_recv>
    return r;
}
  803323:	c9                   	leave  
  803324:	c3                   	ret    

00803325 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  803325:	55                   	push   %ebp
  803326:	89 e5                	mov    %esp,%ebp
  803328:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80332b:	8b 45 08             	mov    0x8(%ebp),%eax
  80332e:	a3 00 70 80 00       	mov    %eax,0x807000
	nsipcbuf.socket.req_type = type;
  803333:	8b 45 0c             	mov    0xc(%ebp),%eax
  803336:	a3 04 70 80 00       	mov    %eax,0x807004
	nsipcbuf.socket.req_protocol = protocol;
  80333b:	8b 45 10             	mov    0x10(%ebp),%eax
  80333e:	a3 08 70 80 00       	mov    %eax,0x807008
	return nsipc(NSREQ_SOCKET);
  803343:	b8 09 00 00 00       	mov    $0x9,%eax
  803348:	e8 93 ff ff ff       	call   8032e0 <nsipc>
}
  80334d:	c9                   	leave  
  80334e:	c3                   	ret    

0080334f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80334f:	55                   	push   %ebp
  803350:	89 e5                	mov    %esp,%ebp
  803352:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  803355:	8b 45 08             	mov    0x8(%ebp),%eax
  803358:	a3 00 70 80 00       	mov    %eax,0x807000
	nsipcbuf.listen.req_backlog = backlog;
  80335d:	8b 45 0c             	mov    0xc(%ebp),%eax
  803360:	a3 04 70 80 00       	mov    %eax,0x807004
	return nsipc(NSREQ_LISTEN);
  803365:	b8 06 00 00 00       	mov    $0x6,%eax
  80336a:	e8 71 ff ff ff       	call   8032e0 <nsipc>
}
  80336f:	c9                   	leave  
  803370:	c3                   	ret    

00803371 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  803371:	55                   	push   %ebp
  803372:	89 e5                	mov    %esp,%ebp
  803374:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  803377:	8b 45 08             	mov    0x8(%ebp),%eax
  80337a:	a3 00 70 80 00       	mov    %eax,0x807000
	return nsipc(NSREQ_CLOSE);
  80337f:	b8 04 00 00 00       	mov    $0x4,%eax
  803384:	e8 57 ff ff ff       	call   8032e0 <nsipc>
}
  803389:	c9                   	leave  
  80338a:	c3                   	ret    

0080338b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80338b:	55                   	push   %ebp
  80338c:	89 e5                	mov    %esp,%ebp
  80338e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  803391:	8b 45 08             	mov    0x8(%ebp),%eax
  803394:	a3 00 70 80 00       	mov    %eax,0x807000
	nsipcbuf.shutdown.req_how = how;
  803399:	8b 45 0c             	mov    0xc(%ebp),%eax
  80339c:	a3 04 70 80 00       	mov    %eax,0x807004
	return nsipc(NSREQ_SHUTDOWN);
  8033a1:	b8 03 00 00 00       	mov    $0x3,%eax
  8033a6:	e8 35 ff ff ff       	call   8032e0 <nsipc>
}
  8033ab:	c9                   	leave  
  8033ac:	c3                   	ret    

008033ad <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  8033ad:	55                   	push   %ebp
  8033ae:	89 e5                	mov    %esp,%ebp
  8033b0:	53                   	push   %ebx
  8033b1:	83 ec 14             	sub    $0x14,%esp
  8033b4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  8033b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8033ba:	a3 00 70 80 00       	mov    %eax,0x807000
	assert(size < 1600);
  8033bf:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8033c5:	7e 24                	jle    8033eb <nsipc_send+0x3e>
  8033c7:	c7 44 24 0c 9a 46 80 	movl   $0x80469a,0xc(%esp)
  8033ce:	00 
  8033cf:	c7 44 24 08 a1 3f 80 	movl   $0x803fa1,0x8(%esp)
  8033d6:	00 
  8033d7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8033de:	00 
  8033df:	c7 04 24 a6 46 80 00 	movl   $0x8046a6,(%esp)
  8033e6:	e8 15 d7 ff ff       	call   800b00 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8033eb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8033ef:	8b 45 0c             	mov    0xc(%ebp),%eax
  8033f2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8033f6:	c7 04 24 0c 70 80 00 	movl   $0x80700c,(%esp)
  8033fd:	e8 43 e1 ff ff       	call   801545 <memmove>
	nsipcbuf.send.req_size = size;
  803402:	89 1d 04 70 80 00    	mov    %ebx,0x807004
	nsipcbuf.send.req_flags = flags;
  803408:	8b 45 14             	mov    0x14(%ebp),%eax
  80340b:	a3 08 70 80 00       	mov    %eax,0x807008
	return nsipc(NSREQ_SEND);
  803410:	b8 08 00 00 00       	mov    $0x8,%eax
  803415:	e8 c6 fe ff ff       	call   8032e0 <nsipc>
}
  80341a:	83 c4 14             	add    $0x14,%esp
  80341d:	5b                   	pop    %ebx
  80341e:	5d                   	pop    %ebp
  80341f:	c3                   	ret    

00803420 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  803420:	55                   	push   %ebp
  803421:	89 e5                	mov    %esp,%ebp
  803423:	56                   	push   %esi
  803424:	53                   	push   %ebx
  803425:	83 ec 10             	sub    $0x10,%esp
  803428:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80342b:	8b 45 08             	mov    0x8(%ebp),%eax
  80342e:	a3 00 70 80 00       	mov    %eax,0x807000
	nsipcbuf.recv.req_len = len;
  803433:	89 35 04 70 80 00    	mov    %esi,0x807004
	nsipcbuf.recv.req_flags = flags;
  803439:	8b 45 14             	mov    0x14(%ebp),%eax
  80343c:	a3 08 70 80 00       	mov    %eax,0x807008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  803441:	b8 07 00 00 00       	mov    $0x7,%eax
  803446:	e8 95 fe ff ff       	call   8032e0 <nsipc>
  80344b:	89 c3                	mov    %eax,%ebx
  80344d:	85 c0                	test   %eax,%eax
  80344f:	78 46                	js     803497 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  803451:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  803456:	7f 04                	jg     80345c <nsipc_recv+0x3c>
  803458:	39 c6                	cmp    %eax,%esi
  80345a:	7d 24                	jge    803480 <nsipc_recv+0x60>
  80345c:	c7 44 24 0c b2 46 80 	movl   $0x8046b2,0xc(%esp)
  803463:	00 
  803464:	c7 44 24 08 a1 3f 80 	movl   $0x803fa1,0x8(%esp)
  80346b:	00 
  80346c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  803473:	00 
  803474:	c7 04 24 a6 46 80 00 	movl   $0x8046a6,(%esp)
  80347b:	e8 80 d6 ff ff       	call   800b00 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  803480:	89 44 24 08          	mov    %eax,0x8(%esp)
  803484:	c7 44 24 04 00 70 80 	movl   $0x807000,0x4(%esp)
  80348b:	00 
  80348c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80348f:	89 04 24             	mov    %eax,(%esp)
  803492:	e8 ae e0 ff ff       	call   801545 <memmove>
	}

	return r;
}
  803497:	89 d8                	mov    %ebx,%eax
  803499:	83 c4 10             	add    $0x10,%esp
  80349c:	5b                   	pop    %ebx
  80349d:	5e                   	pop    %esi
  80349e:	5d                   	pop    %ebp
  80349f:	c3                   	ret    

008034a0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8034a0:	55                   	push   %ebp
  8034a1:	89 e5                	mov    %esp,%ebp
  8034a3:	53                   	push   %ebx
  8034a4:	83 ec 14             	sub    $0x14,%esp
  8034a7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8034aa:	8b 45 08             	mov    0x8(%ebp),%eax
  8034ad:	a3 00 70 80 00       	mov    %eax,0x807000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8034b2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8034b6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8034b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8034bd:	c7 04 24 04 70 80 00 	movl   $0x807004,(%esp)
  8034c4:	e8 7c e0 ff ff       	call   801545 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8034c9:	89 1d 14 70 80 00    	mov    %ebx,0x807014
	return nsipc(NSREQ_CONNECT);
  8034cf:	b8 05 00 00 00       	mov    $0x5,%eax
  8034d4:	e8 07 fe ff ff       	call   8032e0 <nsipc>
}
  8034d9:	83 c4 14             	add    $0x14,%esp
  8034dc:	5b                   	pop    %ebx
  8034dd:	5d                   	pop    %ebp
  8034de:	c3                   	ret    

008034df <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8034df:	55                   	push   %ebp
  8034e0:	89 e5                	mov    %esp,%ebp
  8034e2:	53                   	push   %ebx
  8034e3:	83 ec 14             	sub    $0x14,%esp
  8034e6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8034e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8034ec:	a3 00 70 80 00       	mov    %eax,0x807000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8034f1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8034f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8034f8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8034fc:	c7 04 24 04 70 80 00 	movl   $0x807004,(%esp)
  803503:	e8 3d e0 ff ff       	call   801545 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  803508:	89 1d 14 70 80 00    	mov    %ebx,0x807014
	return nsipc(NSREQ_BIND);
  80350e:	b8 02 00 00 00       	mov    $0x2,%eax
  803513:	e8 c8 fd ff ff       	call   8032e0 <nsipc>
}
  803518:	83 c4 14             	add    $0x14,%esp
  80351b:	5b                   	pop    %ebx
  80351c:	5d                   	pop    %ebp
  80351d:	c3                   	ret    

0080351e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80351e:	55                   	push   %ebp
  80351f:	89 e5                	mov    %esp,%ebp
  803521:	83 ec 18             	sub    $0x18,%esp
  803524:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  803527:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80352a:	8b 45 08             	mov    0x8(%ebp),%eax
  80352d:	a3 00 70 80 00       	mov    %eax,0x807000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  803532:	b8 01 00 00 00       	mov    $0x1,%eax
  803537:	e8 a4 fd ff ff       	call   8032e0 <nsipc>
  80353c:	89 c3                	mov    %eax,%ebx
  80353e:	85 c0                	test   %eax,%eax
  803540:	78 25                	js     803567 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  803542:	be 10 70 80 00       	mov    $0x807010,%esi
  803547:	8b 06                	mov    (%esi),%eax
  803549:	89 44 24 08          	mov    %eax,0x8(%esp)
  80354d:	c7 44 24 04 00 70 80 	movl   $0x807000,0x4(%esp)
  803554:	00 
  803555:	8b 45 0c             	mov    0xc(%ebp),%eax
  803558:	89 04 24             	mov    %eax,(%esp)
  80355b:	e8 e5 df ff ff       	call   801545 <memmove>
		*addrlen = ret->ret_addrlen;
  803560:	8b 16                	mov    (%esi),%edx
  803562:	8b 45 10             	mov    0x10(%ebp),%eax
  803565:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  803567:	89 d8                	mov    %ebx,%eax
  803569:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80356c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80356f:	89 ec                	mov    %ebp,%esp
  803571:	5d                   	pop    %ebp
  803572:	c3                   	ret    
	...

00803580 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  803580:	55                   	push   %ebp
  803581:	89 e5                	mov    %esp,%ebp
  803583:	83 ec 18             	sub    $0x18,%esp
  803586:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  803589:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80358c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80358f:	8b 45 08             	mov    0x8(%ebp),%eax
  803592:	89 04 24             	mov    %eax,(%esp)
  803595:	e8 86 ea ff ff       	call   802020 <fd2data>
  80359a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80359c:	c7 44 24 04 c7 46 80 	movl   $0x8046c7,0x4(%esp)
  8035a3:	00 
  8035a4:	89 34 24             	mov    %esi,(%esp)
  8035a7:	e8 de dd ff ff       	call   80138a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8035ac:	8b 43 04             	mov    0x4(%ebx),%eax
  8035af:	2b 03                	sub    (%ebx),%eax
  8035b1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  8035b7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  8035be:	00 00 00 
	stat->st_dev = &devpipe;
  8035c1:	c7 86 88 00 00 00 58 	movl   $0x808058,0x88(%esi)
  8035c8:	80 80 00 
	return 0;
}
  8035cb:	b8 00 00 00 00       	mov    $0x0,%eax
  8035d0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8035d3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8035d6:	89 ec                	mov    %ebp,%esp
  8035d8:	5d                   	pop    %ebp
  8035d9:	c3                   	ret    

008035da <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8035da:	55                   	push   %ebp
  8035db:	89 e5                	mov    %esp,%ebp
  8035dd:	53                   	push   %ebx
  8035de:	83 ec 14             	sub    $0x14,%esp
  8035e1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8035e4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8035e8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8035ef:	e8 36 e4 ff ff       	call   801a2a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8035f4:	89 1c 24             	mov    %ebx,(%esp)
  8035f7:	e8 24 ea ff ff       	call   802020 <fd2data>
  8035fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  803600:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803607:	e8 1e e4 ff ff       	call   801a2a <sys_page_unmap>
}
  80360c:	83 c4 14             	add    $0x14,%esp
  80360f:	5b                   	pop    %ebx
  803610:	5d                   	pop    %ebp
  803611:	c3                   	ret    

00803612 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  803612:	55                   	push   %ebp
  803613:	89 e5                	mov    %esp,%ebp
  803615:	57                   	push   %edi
  803616:	56                   	push   %esi
  803617:	53                   	push   %ebx
  803618:	83 ec 2c             	sub    $0x2c,%esp
  80361b:	89 c7                	mov    %eax,%edi
  80361d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  803620:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  803625:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  803628:	89 3c 24             	mov    %edi,(%esp)
  80362b:	e8 f4 04 00 00       	call   803b24 <pageref>
  803630:	89 c6                	mov    %eax,%esi
  803632:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  803635:	89 04 24             	mov    %eax,(%esp)
  803638:	e8 e7 04 00 00       	call   803b24 <pageref>
  80363d:	39 c6                	cmp    %eax,%esi
  80363f:	0f 94 c0             	sete   %al
  803642:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  803645:	8b 15 a0 84 80 00    	mov    0x8084a0,%edx
  80364b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80364e:	39 cb                	cmp    %ecx,%ebx
  803650:	75 08                	jne    80365a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  803652:	83 c4 2c             	add    $0x2c,%esp
  803655:	5b                   	pop    %ebx
  803656:	5e                   	pop    %esi
  803657:	5f                   	pop    %edi
  803658:	5d                   	pop    %ebp
  803659:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80365a:	83 f8 01             	cmp    $0x1,%eax
  80365d:	75 c1                	jne    803620 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80365f:	8b 52 58             	mov    0x58(%edx),%edx
  803662:	89 44 24 0c          	mov    %eax,0xc(%esp)
  803666:	89 54 24 08          	mov    %edx,0x8(%esp)
  80366a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80366e:	c7 04 24 ce 46 80 00 	movl   $0x8046ce,(%esp)
  803675:	e8 4b d5 ff ff       	call   800bc5 <cprintf>
  80367a:	eb a4                	jmp    803620 <_pipeisclosed+0xe>

0080367c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80367c:	55                   	push   %ebp
  80367d:	89 e5                	mov    %esp,%ebp
  80367f:	57                   	push   %edi
  803680:	56                   	push   %esi
  803681:	53                   	push   %ebx
  803682:	83 ec 1c             	sub    $0x1c,%esp
  803685:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  803688:	89 34 24             	mov    %esi,(%esp)
  80368b:	e8 90 e9 ff ff       	call   802020 <fd2data>
  803690:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  803692:	bf 00 00 00 00       	mov    $0x0,%edi
  803697:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80369b:	75 54                	jne    8036f1 <devpipe_write+0x75>
  80369d:	eb 60                	jmp    8036ff <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80369f:	89 da                	mov    %ebx,%edx
  8036a1:	89 f0                	mov    %esi,%eax
  8036a3:	e8 6a ff ff ff       	call   803612 <_pipeisclosed>
  8036a8:	85 c0                	test   %eax,%eax
  8036aa:	74 07                	je     8036b3 <devpipe_write+0x37>
  8036ac:	b8 00 00 00 00       	mov    $0x0,%eax
  8036b1:	eb 53                	jmp    803706 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  8036b3:	90                   	nop
  8036b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8036b8:	e8 88 e4 ff ff       	call   801b45 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8036bd:	8b 43 04             	mov    0x4(%ebx),%eax
  8036c0:	8b 13                	mov    (%ebx),%edx
  8036c2:	83 c2 20             	add    $0x20,%edx
  8036c5:	39 d0                	cmp    %edx,%eax
  8036c7:	73 d6                	jae    80369f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8036c9:	89 c2                	mov    %eax,%edx
  8036cb:	c1 fa 1f             	sar    $0x1f,%edx
  8036ce:	c1 ea 1b             	shr    $0x1b,%edx
  8036d1:	01 d0                	add    %edx,%eax
  8036d3:	83 e0 1f             	and    $0x1f,%eax
  8036d6:	29 d0                	sub    %edx,%eax
  8036d8:	89 c2                	mov    %eax,%edx
  8036da:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8036dd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8036e1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8036e5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8036e9:	83 c7 01             	add    $0x1,%edi
  8036ec:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8036ef:	76 13                	jbe    803704 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8036f1:	8b 43 04             	mov    0x4(%ebx),%eax
  8036f4:	8b 13                	mov    (%ebx),%edx
  8036f6:	83 c2 20             	add    $0x20,%edx
  8036f9:	39 d0                	cmp    %edx,%eax
  8036fb:	73 a2                	jae    80369f <devpipe_write+0x23>
  8036fd:	eb ca                	jmp    8036c9 <devpipe_write+0x4d>
  8036ff:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  803704:	89 f8                	mov    %edi,%eax
}
  803706:	83 c4 1c             	add    $0x1c,%esp
  803709:	5b                   	pop    %ebx
  80370a:	5e                   	pop    %esi
  80370b:	5f                   	pop    %edi
  80370c:	5d                   	pop    %ebp
  80370d:	c3                   	ret    

0080370e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80370e:	55                   	push   %ebp
  80370f:	89 e5                	mov    %esp,%ebp
  803711:	83 ec 28             	sub    $0x28,%esp
  803714:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  803717:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80371a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80371d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  803720:	89 3c 24             	mov    %edi,(%esp)
  803723:	e8 f8 e8 ff ff       	call   802020 <fd2data>
  803728:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80372a:	be 00 00 00 00       	mov    $0x0,%esi
  80372f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  803733:	75 4c                	jne    803781 <devpipe_read+0x73>
  803735:	eb 5b                	jmp    803792 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  803737:	89 f0                	mov    %esi,%eax
  803739:	eb 5e                	jmp    803799 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80373b:	89 da                	mov    %ebx,%edx
  80373d:	89 f8                	mov    %edi,%eax
  80373f:	90                   	nop
  803740:	e8 cd fe ff ff       	call   803612 <_pipeisclosed>
  803745:	85 c0                	test   %eax,%eax
  803747:	74 07                	je     803750 <devpipe_read+0x42>
  803749:	b8 00 00 00 00       	mov    $0x0,%eax
  80374e:	eb 49                	jmp    803799 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  803750:	e8 f0 e3 ff ff       	call   801b45 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  803755:	8b 03                	mov    (%ebx),%eax
  803757:	3b 43 04             	cmp    0x4(%ebx),%eax
  80375a:	74 df                	je     80373b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80375c:	89 c2                	mov    %eax,%edx
  80375e:	c1 fa 1f             	sar    $0x1f,%edx
  803761:	c1 ea 1b             	shr    $0x1b,%edx
  803764:	01 d0                	add    %edx,%eax
  803766:	83 e0 1f             	and    $0x1f,%eax
  803769:	29 d0                	sub    %edx,%eax
  80376b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  803770:	8b 55 0c             	mov    0xc(%ebp),%edx
  803773:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  803776:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  803779:	83 c6 01             	add    $0x1,%esi
  80377c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80377f:	76 16                	jbe    803797 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  803781:	8b 03                	mov    (%ebx),%eax
  803783:	3b 43 04             	cmp    0x4(%ebx),%eax
  803786:	75 d4                	jne    80375c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  803788:	85 f6                	test   %esi,%esi
  80378a:	75 ab                	jne    803737 <devpipe_read+0x29>
  80378c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803790:	eb a9                	jmp    80373b <devpipe_read+0x2d>
  803792:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  803797:	89 f0                	mov    %esi,%eax
}
  803799:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80379c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80379f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8037a2:	89 ec                	mov    %ebp,%esp
  8037a4:	5d                   	pop    %ebp
  8037a5:	c3                   	ret    

008037a6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  8037a6:	55                   	push   %ebp
  8037a7:	89 e5                	mov    %esp,%ebp
  8037a9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8037ac:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8037af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8037b3:	8b 45 08             	mov    0x8(%ebp),%eax
  8037b6:	89 04 24             	mov    %eax,(%esp)
  8037b9:	e8 ef e8 ff ff       	call   8020ad <fd_lookup>
  8037be:	85 c0                	test   %eax,%eax
  8037c0:	78 15                	js     8037d7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  8037c2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8037c5:	89 04 24             	mov    %eax,(%esp)
  8037c8:	e8 53 e8 ff ff       	call   802020 <fd2data>
	return _pipeisclosed(fd, p);
  8037cd:	89 c2                	mov    %eax,%edx
  8037cf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8037d2:	e8 3b fe ff ff       	call   803612 <_pipeisclosed>
}
  8037d7:	c9                   	leave  
  8037d8:	c3                   	ret    

008037d9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8037d9:	55                   	push   %ebp
  8037da:	89 e5                	mov    %esp,%ebp
  8037dc:	83 ec 48             	sub    $0x48,%esp
  8037df:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8037e2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8037e5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8037e8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8037eb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8037ee:	89 04 24             	mov    %eax,(%esp)
  8037f1:	e8 45 e8 ff ff       	call   80203b <fd_alloc>
  8037f6:	89 c3                	mov    %eax,%ebx
  8037f8:	85 c0                	test   %eax,%eax
  8037fa:	0f 88 42 01 00 00    	js     803942 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  803800:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  803807:	00 
  803808:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80380b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80380f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803816:	e8 cb e2 ff ff       	call   801ae6 <sys_page_alloc>
  80381b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80381d:	85 c0                	test   %eax,%eax
  80381f:	0f 88 1d 01 00 00    	js     803942 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  803825:	8d 45 e0             	lea    -0x20(%ebp),%eax
  803828:	89 04 24             	mov    %eax,(%esp)
  80382b:	e8 0b e8 ff ff       	call   80203b <fd_alloc>
  803830:	89 c3                	mov    %eax,%ebx
  803832:	85 c0                	test   %eax,%eax
  803834:	0f 88 f5 00 00 00    	js     80392f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80383a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  803841:	00 
  803842:	8b 45 e0             	mov    -0x20(%ebp),%eax
  803845:	89 44 24 04          	mov    %eax,0x4(%esp)
  803849:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803850:	e8 91 e2 ff ff       	call   801ae6 <sys_page_alloc>
  803855:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  803857:	85 c0                	test   %eax,%eax
  803859:	0f 88 d0 00 00 00    	js     80392f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80385f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  803862:	89 04 24             	mov    %eax,(%esp)
  803865:	e8 b6 e7 ff ff       	call   802020 <fd2data>
  80386a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80386c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  803873:	00 
  803874:	89 44 24 04          	mov    %eax,0x4(%esp)
  803878:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80387f:	e8 62 e2 ff ff       	call   801ae6 <sys_page_alloc>
  803884:	89 c3                	mov    %eax,%ebx
  803886:	85 c0                	test   %eax,%eax
  803888:	0f 88 8e 00 00 00    	js     80391c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80388e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  803891:	89 04 24             	mov    %eax,(%esp)
  803894:	e8 87 e7 ff ff       	call   802020 <fd2data>
  803899:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  8038a0:	00 
  8038a1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8038a5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8038ac:	00 
  8038ad:	89 74 24 04          	mov    %esi,0x4(%esp)
  8038b1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8038b8:	e8 cb e1 ff ff       	call   801a88 <sys_page_map>
  8038bd:	89 c3                	mov    %eax,%ebx
  8038bf:	85 c0                	test   %eax,%eax
  8038c1:	78 49                	js     80390c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  8038c3:	b8 58 80 80 00       	mov    $0x808058,%eax
  8038c8:	8b 08                	mov    (%eax),%ecx
  8038ca:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8038cd:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  8038cf:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8038d2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8038d9:	8b 10                	mov    (%eax),%edx
  8038db:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8038de:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8038e0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8038e3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8038ea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8038ed:	89 04 24             	mov    %eax,(%esp)
  8038f0:	e8 1b e7 ff ff       	call   802010 <fd2num>
  8038f5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8038f7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8038fa:	89 04 24             	mov    %eax,(%esp)
  8038fd:	e8 0e e7 ff ff       	call   802010 <fd2num>
  803902:	89 47 04             	mov    %eax,0x4(%edi)
  803905:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  80390a:	eb 36                	jmp    803942 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  80390c:	89 74 24 04          	mov    %esi,0x4(%esp)
  803910:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803917:	e8 0e e1 ff ff       	call   801a2a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  80391c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80391f:	89 44 24 04          	mov    %eax,0x4(%esp)
  803923:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80392a:	e8 fb e0 ff ff       	call   801a2a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  80392f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  803932:	89 44 24 04          	mov    %eax,0x4(%esp)
  803936:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80393d:	e8 e8 e0 ff ff       	call   801a2a <sys_page_unmap>
    err:
	return r;
}
  803942:	89 d8                	mov    %ebx,%eax
  803944:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  803947:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80394a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80394d:	89 ec                	mov    %ebp,%esp
  80394f:	5d                   	pop    %ebp
  803950:	c3                   	ret    
  803951:	00 00                	add    %al,(%eax)
	...

00803954 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  803954:	55                   	push   %ebp
  803955:	89 e5                	mov    %esp,%ebp
  803957:	56                   	push   %esi
  803958:	53                   	push   %ebx
  803959:	83 ec 10             	sub    $0x10,%esp
  80395c:	8b 45 08             	mov    0x8(%ebp),%eax
	volatile struct Env *e;

	assert(envid != 0);
  80395f:	85 c0                	test   %eax,%eax
  803961:	75 24                	jne    803987 <wait+0x33>
  803963:	c7 44 24 0c e6 46 80 	movl   $0x8046e6,0xc(%esp)
  80396a:	00 
  80396b:	c7 44 24 08 a1 3f 80 	movl   $0x803fa1,0x8(%esp)
  803972:	00 
  803973:	c7 44 24 04 09 00 00 	movl   $0x9,0x4(%esp)
  80397a:	00 
  80397b:	c7 04 24 f1 46 80 00 	movl   $0x8046f1,(%esp)
  803982:	e8 79 d1 ff ff       	call   800b00 <_panic>
	e = &envs[ENVX(envid)];
  803987:	89 c3                	mov    %eax,%ebx
  803989:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
  80398f:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  803992:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  803998:	8b 73 4c             	mov    0x4c(%ebx),%esi
  80399b:	39 c6                	cmp    %eax,%esi
  80399d:	75 1a                	jne    8039b9 <wait+0x65>
  80399f:	8b 43 54             	mov    0x54(%ebx),%eax
  8039a2:	85 c0                	test   %eax,%eax
  8039a4:	74 13                	je     8039b9 <wait+0x65>
		sys_yield();
  8039a6:	e8 9a e1 ff ff       	call   801b45 <sys_yield>
{
	volatile struct Env *e;

	assert(envid != 0);
	e = &envs[ENVX(envid)];
	while (e->env_id == envid && e->env_status != ENV_FREE)
  8039ab:	8b 43 4c             	mov    0x4c(%ebx),%eax
  8039ae:	39 f0                	cmp    %esi,%eax
  8039b0:	75 07                	jne    8039b9 <wait+0x65>
  8039b2:	8b 43 54             	mov    0x54(%ebx),%eax
  8039b5:	85 c0                	test   %eax,%eax
  8039b7:	75 ed                	jne    8039a6 <wait+0x52>
		sys_yield();
}
  8039b9:	83 c4 10             	add    $0x10,%esp
  8039bc:	5b                   	pop    %ebx
  8039bd:	5e                   	pop    %esi
  8039be:	5d                   	pop    %ebp
  8039bf:	c3                   	ret    

008039c0 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  8039c0:	55                   	push   %ebp
  8039c1:	89 e5                	mov    %esp,%ebp
  8039c3:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  8039c6:	83 3d a8 84 80 00 00 	cmpl   $0x0,0x8084a8
  8039cd:	75 55                	jne    803a24 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  8039cf:	e8 a5 e1 ff ff       	call   801b79 <sys_getenvid>
  8039d4:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8039db:	00 
  8039dc:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  8039e3:	ee 
  8039e4:	89 04 24             	mov    %eax,(%esp)
  8039e7:	e8 fa e0 ff ff       	call   801ae6 <sys_page_alloc>
  8039ec:	85 c0                	test   %eax,%eax
  8039ee:	74 1c                	je     803a0c <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  8039f0:	c7 44 24 08 fc 46 80 	movl   $0x8046fc,0x8(%esp)
  8039f7:	00 
  8039f8:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  8039ff:	00 
  803a00:	c7 04 24 20 47 80 00 	movl   $0x804720,(%esp)
  803a07:	e8 f4 d0 ff ff       	call   800b00 <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  803a0c:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  803a11:	8b 40 4c             	mov    0x4c(%eax),%eax
  803a14:	c7 44 24 04 30 3a 80 	movl   $0x803a30,0x4(%esp)
  803a1b:	00 
  803a1c:	89 04 24             	mov    %eax,(%esp)
  803a1f:	e8 ec de ff ff       	call   801910 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  803a24:	8b 45 08             	mov    0x8(%ebp),%eax
  803a27:	a3 a8 84 80 00       	mov    %eax,0x8084a8
}
  803a2c:	c9                   	leave  
  803a2d:	c3                   	ret    
	...

00803a30 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  803a30:	54                   	push   %esp
	movl _pgfault_handler, %eax
  803a31:	a1 a8 84 80 00       	mov    0x8084a8,%eax
	call *%eax
  803a36:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  803a38:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  803a3b:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  803a40:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  803a44:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  803a48:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  803a4a:	83 c4 08             	add    $0x8,%esp
    popal
  803a4d:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  803a4e:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  803a52:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  803a53:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  803a57:	c3                   	ret    
	...

00803a60 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  803a60:	55                   	push   %ebp
  803a61:	89 e5                	mov    %esp,%ebp
  803a63:	57                   	push   %edi
  803a64:	56                   	push   %esi
  803a65:	53                   	push   %ebx
  803a66:	83 ec 2c             	sub    $0x2c,%esp
  803a69:	8b 75 08             	mov    0x8(%ebp),%esi
  803a6c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  803a6f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  803a72:	85 db                	test   %ebx,%ebx
  803a74:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  803a79:	0f 45 c3             	cmovne %ebx,%eax
  803a7c:	8b 55 14             	mov    0x14(%ebp),%edx
  803a7f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  803a83:	89 44 24 08          	mov    %eax,0x8(%esp)
  803a87:	89 7c 24 04          	mov    %edi,0x4(%esp)
  803a8b:	89 34 24             	mov    %esi,(%esp)
  803a8e:	e8 1d de ff ff       	call   8018b0 <sys_ipc_try_send>
  803a93:	83 f8 f9             	cmp    $0xfffffff9,%eax
  803a96:	75 0a                	jne    803aa2 <ipc_send+0x42>
      sys_yield();
  803a98:	e8 a8 e0 ff ff       	call   801b45 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  803a9d:	8d 76 00             	lea    0x0(%esi),%esi
  803aa0:	eb d0                	jmp    803a72 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  803aa2:	85 c0                	test   %eax,%eax
  803aa4:	79 24                	jns    803aca <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  803aa6:	89 44 24 10          	mov    %eax,0x10(%esp)
  803aaa:	89 74 24 0c          	mov    %esi,0xc(%esp)
  803aae:	c7 44 24 08 30 47 80 	movl   $0x804730,0x8(%esp)
  803ab5:	00 
  803ab6:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  803abd:	00 
  803abe:	c7 04 24 54 47 80 00 	movl   $0x804754,(%esp)
  803ac5:	e8 36 d0 ff ff       	call   800b00 <_panic>
    else
      return;
  }
}
  803aca:	83 c4 2c             	add    $0x2c,%esp
  803acd:	5b                   	pop    %ebx
  803ace:	5e                   	pop    %esi
  803acf:	5f                   	pop    %edi
  803ad0:	5d                   	pop    %ebp
  803ad1:	c3                   	ret    

00803ad2 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  803ad2:	55                   	push   %ebp
  803ad3:	89 e5                	mov    %esp,%ebp
  803ad5:	56                   	push   %esi
  803ad6:	53                   	push   %ebx
  803ad7:	83 ec 10             	sub    $0x10,%esp
  803ada:	8b 5d 08             	mov    0x8(%ebp),%ebx
  803add:	8b 45 0c             	mov    0xc(%ebp),%eax
  803ae0:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  803ae3:	85 c0                	test   %eax,%eax
  803ae5:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  803aea:	0f 44 c2             	cmove  %edx,%eax
  803aed:	89 04 24             	mov    %eax,(%esp)
  803af0:	e8 5e dd ff ff       	call   801853 <sys_ipc_recv>
  803af5:	85 c0                	test   %eax,%eax
  803af7:	78 24                	js     803b1d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  803af9:	85 db                	test   %ebx,%ebx
  803afb:	74 0a                	je     803b07 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  803afd:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  803b02:	8b 40 74             	mov    0x74(%eax),%eax
  803b05:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  803b07:	85 f6                	test   %esi,%esi
  803b09:	74 0a                	je     803b15 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  803b0b:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  803b10:	8b 40 78             	mov    0x78(%eax),%eax
  803b13:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  803b15:	a1 a0 84 80 00       	mov    0x8084a0,%eax
  803b1a:	8b 40 70             	mov    0x70(%eax),%eax
}
  803b1d:	83 c4 10             	add    $0x10,%esp
  803b20:	5b                   	pop    %ebx
  803b21:	5e                   	pop    %esi
  803b22:	5d                   	pop    %ebp
  803b23:	c3                   	ret    

00803b24 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  803b24:	55                   	push   %ebp
  803b25:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  803b27:	8b 45 08             	mov    0x8(%ebp),%eax
  803b2a:	89 c2                	mov    %eax,%edx
  803b2c:	c1 ea 16             	shr    $0x16,%edx
  803b2f:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  803b36:	f6 c2 01             	test   $0x1,%dl
  803b39:	74 26                	je     803b61 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  803b3b:	c1 e8 0c             	shr    $0xc,%eax
  803b3e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  803b45:	a8 01                	test   $0x1,%al
  803b47:	74 18                	je     803b61 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  803b49:	c1 e8 0c             	shr    $0xc,%eax
  803b4c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  803b4f:	c1 e2 02             	shl    $0x2,%edx
  803b52:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  803b57:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  803b5c:	0f b7 c0             	movzwl %ax,%eax
  803b5f:	eb 05                	jmp    803b66 <pageref+0x42>
  803b61:	b8 00 00 00 00       	mov    $0x0,%eax
}
  803b66:	5d                   	pop    %ebp
  803b67:	c3                   	ret    
	...

00803b70 <__udivdi3>:
  803b70:	55                   	push   %ebp
  803b71:	89 e5                	mov    %esp,%ebp
  803b73:	57                   	push   %edi
  803b74:	56                   	push   %esi
  803b75:	83 ec 10             	sub    $0x10,%esp
  803b78:	8b 45 14             	mov    0x14(%ebp),%eax
  803b7b:	8b 55 08             	mov    0x8(%ebp),%edx
  803b7e:	8b 75 10             	mov    0x10(%ebp),%esi
  803b81:	8b 7d 0c             	mov    0xc(%ebp),%edi
  803b84:	85 c0                	test   %eax,%eax
  803b86:	89 55 f0             	mov    %edx,-0x10(%ebp)
  803b89:	75 35                	jne    803bc0 <__udivdi3+0x50>
  803b8b:	39 fe                	cmp    %edi,%esi
  803b8d:	77 61                	ja     803bf0 <__udivdi3+0x80>
  803b8f:	85 f6                	test   %esi,%esi
  803b91:	75 0b                	jne    803b9e <__udivdi3+0x2e>
  803b93:	b8 01 00 00 00       	mov    $0x1,%eax
  803b98:	31 d2                	xor    %edx,%edx
  803b9a:	f7 f6                	div    %esi
  803b9c:	89 c6                	mov    %eax,%esi
  803b9e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  803ba1:	31 d2                	xor    %edx,%edx
  803ba3:	89 f8                	mov    %edi,%eax
  803ba5:	f7 f6                	div    %esi
  803ba7:	89 c7                	mov    %eax,%edi
  803ba9:	89 c8                	mov    %ecx,%eax
  803bab:	f7 f6                	div    %esi
  803bad:	89 c1                	mov    %eax,%ecx
  803baf:	89 fa                	mov    %edi,%edx
  803bb1:	89 c8                	mov    %ecx,%eax
  803bb3:	83 c4 10             	add    $0x10,%esp
  803bb6:	5e                   	pop    %esi
  803bb7:	5f                   	pop    %edi
  803bb8:	5d                   	pop    %ebp
  803bb9:	c3                   	ret    
  803bba:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  803bc0:	39 f8                	cmp    %edi,%eax
  803bc2:	77 1c                	ja     803be0 <__udivdi3+0x70>
  803bc4:	0f bd d0             	bsr    %eax,%edx
  803bc7:	83 f2 1f             	xor    $0x1f,%edx
  803bca:	89 55 f4             	mov    %edx,-0xc(%ebp)
  803bcd:	75 39                	jne    803c08 <__udivdi3+0x98>
  803bcf:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  803bd2:	0f 86 a0 00 00 00    	jbe    803c78 <__udivdi3+0x108>
  803bd8:	39 f8                	cmp    %edi,%eax
  803bda:	0f 82 98 00 00 00    	jb     803c78 <__udivdi3+0x108>
  803be0:	31 ff                	xor    %edi,%edi
  803be2:	31 c9                	xor    %ecx,%ecx
  803be4:	89 c8                	mov    %ecx,%eax
  803be6:	89 fa                	mov    %edi,%edx
  803be8:	83 c4 10             	add    $0x10,%esp
  803beb:	5e                   	pop    %esi
  803bec:	5f                   	pop    %edi
  803bed:	5d                   	pop    %ebp
  803bee:	c3                   	ret    
  803bef:	90                   	nop
  803bf0:	89 d1                	mov    %edx,%ecx
  803bf2:	89 fa                	mov    %edi,%edx
  803bf4:	89 c8                	mov    %ecx,%eax
  803bf6:	31 ff                	xor    %edi,%edi
  803bf8:	f7 f6                	div    %esi
  803bfa:	89 c1                	mov    %eax,%ecx
  803bfc:	89 fa                	mov    %edi,%edx
  803bfe:	89 c8                	mov    %ecx,%eax
  803c00:	83 c4 10             	add    $0x10,%esp
  803c03:	5e                   	pop    %esi
  803c04:	5f                   	pop    %edi
  803c05:	5d                   	pop    %ebp
  803c06:	c3                   	ret    
  803c07:	90                   	nop
  803c08:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  803c0c:	89 f2                	mov    %esi,%edx
  803c0e:	d3 e0                	shl    %cl,%eax
  803c10:	89 45 ec             	mov    %eax,-0x14(%ebp)
  803c13:	b8 20 00 00 00       	mov    $0x20,%eax
  803c18:	2b 45 f4             	sub    -0xc(%ebp),%eax
  803c1b:	89 c1                	mov    %eax,%ecx
  803c1d:	d3 ea                	shr    %cl,%edx
  803c1f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  803c23:	0b 55 ec             	or     -0x14(%ebp),%edx
  803c26:	d3 e6                	shl    %cl,%esi
  803c28:	89 c1                	mov    %eax,%ecx
  803c2a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  803c2d:	89 fe                	mov    %edi,%esi
  803c2f:	d3 ee                	shr    %cl,%esi
  803c31:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  803c35:	89 55 ec             	mov    %edx,-0x14(%ebp)
  803c38:	8b 55 f0             	mov    -0x10(%ebp),%edx
  803c3b:	d3 e7                	shl    %cl,%edi
  803c3d:	89 c1                	mov    %eax,%ecx
  803c3f:	d3 ea                	shr    %cl,%edx
  803c41:	09 d7                	or     %edx,%edi
  803c43:	89 f2                	mov    %esi,%edx
  803c45:	89 f8                	mov    %edi,%eax
  803c47:	f7 75 ec             	divl   -0x14(%ebp)
  803c4a:	89 d6                	mov    %edx,%esi
  803c4c:	89 c7                	mov    %eax,%edi
  803c4e:	f7 65 e8             	mull   -0x18(%ebp)
  803c51:	39 d6                	cmp    %edx,%esi
  803c53:	89 55 ec             	mov    %edx,-0x14(%ebp)
  803c56:	72 30                	jb     803c88 <__udivdi3+0x118>
  803c58:	8b 55 f0             	mov    -0x10(%ebp),%edx
  803c5b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  803c5f:	d3 e2                	shl    %cl,%edx
  803c61:	39 c2                	cmp    %eax,%edx
  803c63:	73 05                	jae    803c6a <__udivdi3+0xfa>
  803c65:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  803c68:	74 1e                	je     803c88 <__udivdi3+0x118>
  803c6a:	89 f9                	mov    %edi,%ecx
  803c6c:	31 ff                	xor    %edi,%edi
  803c6e:	e9 71 ff ff ff       	jmp    803be4 <__udivdi3+0x74>
  803c73:	90                   	nop
  803c74:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803c78:	31 ff                	xor    %edi,%edi
  803c7a:	b9 01 00 00 00       	mov    $0x1,%ecx
  803c7f:	e9 60 ff ff ff       	jmp    803be4 <__udivdi3+0x74>
  803c84:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803c88:	8d 4f ff             	lea    -0x1(%edi),%ecx
  803c8b:	31 ff                	xor    %edi,%edi
  803c8d:	89 c8                	mov    %ecx,%eax
  803c8f:	89 fa                	mov    %edi,%edx
  803c91:	83 c4 10             	add    $0x10,%esp
  803c94:	5e                   	pop    %esi
  803c95:	5f                   	pop    %edi
  803c96:	5d                   	pop    %ebp
  803c97:	c3                   	ret    
	...

00803ca0 <__umoddi3>:
  803ca0:	55                   	push   %ebp
  803ca1:	89 e5                	mov    %esp,%ebp
  803ca3:	57                   	push   %edi
  803ca4:	56                   	push   %esi
  803ca5:	83 ec 20             	sub    $0x20,%esp
  803ca8:	8b 55 14             	mov    0x14(%ebp),%edx
  803cab:	8b 4d 08             	mov    0x8(%ebp),%ecx
  803cae:	8b 7d 10             	mov    0x10(%ebp),%edi
  803cb1:	8b 75 0c             	mov    0xc(%ebp),%esi
  803cb4:	85 d2                	test   %edx,%edx
  803cb6:	89 c8                	mov    %ecx,%eax
  803cb8:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  803cbb:	75 13                	jne    803cd0 <__umoddi3+0x30>
  803cbd:	39 f7                	cmp    %esi,%edi
  803cbf:	76 3f                	jbe    803d00 <__umoddi3+0x60>
  803cc1:	89 f2                	mov    %esi,%edx
  803cc3:	f7 f7                	div    %edi
  803cc5:	89 d0                	mov    %edx,%eax
  803cc7:	31 d2                	xor    %edx,%edx
  803cc9:	83 c4 20             	add    $0x20,%esp
  803ccc:	5e                   	pop    %esi
  803ccd:	5f                   	pop    %edi
  803cce:	5d                   	pop    %ebp
  803ccf:	c3                   	ret    
  803cd0:	39 f2                	cmp    %esi,%edx
  803cd2:	77 4c                	ja     803d20 <__umoddi3+0x80>
  803cd4:	0f bd ca             	bsr    %edx,%ecx
  803cd7:	83 f1 1f             	xor    $0x1f,%ecx
  803cda:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  803cdd:	75 51                	jne    803d30 <__umoddi3+0x90>
  803cdf:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  803ce2:	0f 87 e0 00 00 00    	ja     803dc8 <__umoddi3+0x128>
  803ce8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803ceb:	29 f8                	sub    %edi,%eax
  803ced:	19 d6                	sbb    %edx,%esi
  803cef:	89 45 f4             	mov    %eax,-0xc(%ebp)
  803cf2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803cf5:	89 f2                	mov    %esi,%edx
  803cf7:	83 c4 20             	add    $0x20,%esp
  803cfa:	5e                   	pop    %esi
  803cfb:	5f                   	pop    %edi
  803cfc:	5d                   	pop    %ebp
  803cfd:	c3                   	ret    
  803cfe:	66 90                	xchg   %ax,%ax
  803d00:	85 ff                	test   %edi,%edi
  803d02:	75 0b                	jne    803d0f <__umoddi3+0x6f>
  803d04:	b8 01 00 00 00       	mov    $0x1,%eax
  803d09:	31 d2                	xor    %edx,%edx
  803d0b:	f7 f7                	div    %edi
  803d0d:	89 c7                	mov    %eax,%edi
  803d0f:	89 f0                	mov    %esi,%eax
  803d11:	31 d2                	xor    %edx,%edx
  803d13:	f7 f7                	div    %edi
  803d15:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803d18:	f7 f7                	div    %edi
  803d1a:	eb a9                	jmp    803cc5 <__umoddi3+0x25>
  803d1c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803d20:	89 c8                	mov    %ecx,%eax
  803d22:	89 f2                	mov    %esi,%edx
  803d24:	83 c4 20             	add    $0x20,%esp
  803d27:	5e                   	pop    %esi
  803d28:	5f                   	pop    %edi
  803d29:	5d                   	pop    %ebp
  803d2a:	c3                   	ret    
  803d2b:	90                   	nop
  803d2c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803d30:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803d34:	d3 e2                	shl    %cl,%edx
  803d36:	89 55 f4             	mov    %edx,-0xc(%ebp)
  803d39:	ba 20 00 00 00       	mov    $0x20,%edx
  803d3e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  803d41:	89 55 ec             	mov    %edx,-0x14(%ebp)
  803d44:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803d48:	89 fa                	mov    %edi,%edx
  803d4a:	d3 ea                	shr    %cl,%edx
  803d4c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803d50:	0b 55 f4             	or     -0xc(%ebp),%edx
  803d53:	d3 e7                	shl    %cl,%edi
  803d55:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803d59:	89 55 f4             	mov    %edx,-0xc(%ebp)
  803d5c:	89 f2                	mov    %esi,%edx
  803d5e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  803d61:	89 c7                	mov    %eax,%edi
  803d63:	d3 ea                	shr    %cl,%edx
  803d65:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803d69:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  803d6c:	89 c2                	mov    %eax,%edx
  803d6e:	d3 e6                	shl    %cl,%esi
  803d70:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803d74:	d3 ea                	shr    %cl,%edx
  803d76:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803d7a:	09 d6                	or     %edx,%esi
  803d7c:	89 f0                	mov    %esi,%eax
  803d7e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  803d81:	d3 e7                	shl    %cl,%edi
  803d83:	89 f2                	mov    %esi,%edx
  803d85:	f7 75 f4             	divl   -0xc(%ebp)
  803d88:	89 d6                	mov    %edx,%esi
  803d8a:	f7 65 e8             	mull   -0x18(%ebp)
  803d8d:	39 d6                	cmp    %edx,%esi
  803d8f:	72 2b                	jb     803dbc <__umoddi3+0x11c>
  803d91:	39 c7                	cmp    %eax,%edi
  803d93:	72 23                	jb     803db8 <__umoddi3+0x118>
  803d95:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803d99:	29 c7                	sub    %eax,%edi
  803d9b:	19 d6                	sbb    %edx,%esi
  803d9d:	89 f0                	mov    %esi,%eax
  803d9f:	89 f2                	mov    %esi,%edx
  803da1:	d3 ef                	shr    %cl,%edi
  803da3:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803da7:	d3 e0                	shl    %cl,%eax
  803da9:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803dad:	09 f8                	or     %edi,%eax
  803daf:	d3 ea                	shr    %cl,%edx
  803db1:	83 c4 20             	add    $0x20,%esp
  803db4:	5e                   	pop    %esi
  803db5:	5f                   	pop    %edi
  803db6:	5d                   	pop    %ebp
  803db7:	c3                   	ret    
  803db8:	39 d6                	cmp    %edx,%esi
  803dba:	75 d9                	jne    803d95 <__umoddi3+0xf5>
  803dbc:	2b 45 e8             	sub    -0x18(%ebp),%eax
  803dbf:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  803dc2:	eb d1                	jmp    803d95 <__umoddi3+0xf5>
  803dc4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803dc8:	39 f2                	cmp    %esi,%edx
  803dca:	0f 82 18 ff ff ff    	jb     803ce8 <__umoddi3+0x48>
  803dd0:	e9 1d ff ff ff       	jmp    803cf2 <__umoddi3+0x52>
